#include <bits/stdc++.h>
#define pb push_back
#define endl "\n"
#define int long long 
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

void upd(int &x, int y){
    if (x < y) x = y;
}


void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; ++i){
        cin >> x[i];
    }
    reverse(x.begin(), x.end());
    int inf = 1e18;
    vector<vector<int>> dp(m + 1, vector<int> (n + 1, -inf));
    dp[0][n] = 0;
    for (int i = 0; i < m; ++i){
        for (int k = 0; k <= n; ++k){
            if (k != 0){
                upd(dp[i + 1][k - 1], dp[i][k] + x[i]);
            }
            if (k != n){
                upd(dp[i + 1][k + 1], dp[i][k] - x[i]);
            }
        }
    }
    int ans = -inf;
    for (int k = 0; k <= n; ++k){
        upd(ans, dp[m][k]);
    }
    cout << ans << endl;
}



signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    cin >> t;
    while (t--){
        solve();
    }
}