#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll = long long;
using ld = long double;
template <typename t>
ostream& operator<<(ostream& out, const vector<t> &v){
    for(auto x: v)out<<x<<" ";
    return out;
}
template <typename t>
istream& operator>>(istream& in,  vector<t> &v){
    for(auto &x: v)in>>x;
    return in;
}
template <typename t, typename u>
ostream& operator<<(ostream& out, const pair<t, u> p){
    out<<p.first<<" "<<p.second<<"\n";
    return out;
}
template <typename t, typename u>
istream& operator>>(istream& in,  pair<t, u> &p){
    in>>p.first>>p.second;
    return in;
}
__int128_t one = 1;
vector<ll> val, dp, tin, tout, go, mn;
vector<vector<ll>> g;
ll cnt = 0, ans = 0;
bool is_anc(ll par, ll son){
    return tin[par]<=tin[son]&&tout[son]<=tout[par];
}
void dfs(ll v, ll cur, ll base){
    //cout<<v<<" "<<cur<<"\n";
    assert(v!=base);
        cnt++;
        dp[v]++;
    for(auto to: g[v]){
        if((is_anc(v, base)&&(val[to]>mn[v]&&!is_anc(to, base)))||(!is_anc(v, base)&&val[to]>cur)||(is_anc(to, base)&&to!=base)){
            if(is_anc(v, base)&&!is_anc(to, base)){
                cur = mn[v];
            }
            dfs(to, cur, base);
            dp[v]+=dp[to];
        }
    }
    if(!is_anc(v, base))ans = max(ans, dp[v]);
}
ll tim = 0;
void dfsb(ll v){
    tin[v]=tim++;
    for(auto to: g[v])dfsb(to);
    tout[v]=tim++;
}
void solve () {
    ll n, m;
    cin>>n>>m;
    vector<ll> v(m);
    cin>>v;
    reverse(v.begin(), v.end());
    vector<vector<ll>> dp(n+1, vector<ll> (m+1, -1e18));
    dp[0][0]=0;
    for(int j = 0; j<m; j++){
        for(int i = 0; i<=n; i++){
            if(i>0){
                dp[i][j+1]=max(dp[i][j+1], dp[i-1][j]+v[j]);
            }
            if(i<n){
                dp[i][j+1]=max(dp[i][j+1], dp[i+1][j]-v[j]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i<=n; i++){
        ans = max(ans, dp[i][m]);
        //cout<<dp[i]<<"\n";
    }
    cout<<ans<<"\n";
}
signed main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout<<fixed<<setprecision(18);
    ll AnyaSamsonovaGoSex = 1;
    cin>>AnyaSamsonovaGoSex;
    while(AnyaSamsonovaGoSex--) solve();
}