#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ld long double

const int maxn = 2e5;
const int inf = 4e18;
const int LOG = 30;
const int N = 2e3;
const ld eps = 1e-12;

inline void solve() {
    int n, m;
    cin >> n >> m;

    vector<int> x(m);
    for(int &i: x) cin >> i;
    reverse(all(x));

    vector<vector<int>> dp(2, vector<int> (n + 1, -inf));

    int cur = 0, nxt = 1;

    dp[cur][n] = 0;

    for(int i = 0; i < m; i++) {
        dp[nxt].assign(n + 1, -inf);
        for(int cnt = 0; cnt <= n; cnt++) {
            if(cnt) dp[nxt][cnt - 1] = max(dp[nxt][cnt - 1], dp[cur][cnt] + x[i]);
            if(cnt + 1 <= n) dp[nxt][cnt + 1] = max(dp[nxt][cnt + 1], dp[cur][cnt] - x[i]);
        }
        cur ^= 1;
        nxt ^= 1;
    }

    int ans = 0;

    for(int i = 0; i <= n; i += 1) {
        ans = max(dp[cur][i], ans);
    }

    cout << ans << '\n';
    return;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);


#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int tt = 1;
    cin >> tt;

    while(tt--) {
        solve();
    }
    return 0;
}
