#pragma GCC optimize("Ofast,inline")

#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define fi first
#define se second
mt19937 gen(time(0));

const int N = 4e2 + 12;
pair <int,int> dp[2][2*N*N];

void solve() {
    int n, m;
    cin >> n >> m;
    int x[m];
    for(int i = 0; i < m; ++i) {
        cin >> x[i];
    }
    for(int i = 0; i <= 1; ++i) {
        for(int was = -400 * m; was <= 400 * m; ++was) {
            dp[i][was+400*m] = {1e9, -1e9};
        }
    }
    dp[0][400*m] = {0, 0};
    for(int i = 0; i < m; ++i) {
//        cerr << i << endl;
        for(int was = -400 * i; was <= 400 * i; ++was) {
            int nxt = x[i] - was;

            int f = (i % 2);
            dp[1-f][nxt+400*m].fi = min(dp[1-f][nxt+400*m].fi, dp[f][was+400*m].fi);
            dp[1-f][nxt+400*m].se = max(dp[1-f][nxt+400*m].se, dp[f][was+400*m].se);

            dp[1-f][was+400*m].fi = min(dp[1-f][was+400*m].fi, x[i] - dp[f][was+400*m].se);
            dp[1-f][was+400*m].se = max(dp[1-f][was+400*m].se, x[i] - dp[f][was+400*m].fi);
        }
//        cerr << dp[1][1+400*m].fi << ' ' << dp[1][1+400*m].se << endl;
//        cerr << dp[1][0+400*m].fi << ' ' << dp[1][0+400*m].se << endl;
    }
    int ans = -1e18;
    for(int a = -400 * m; a <= 400 * m; ++a) {
        ans = max(ans, dp[m%2][a+400*m].se + a);
//        if(dp[m%2][a+400*m].se != -1e9)
//            cout << a << ' ' << dp[m%2][a+400*m].se << '\n';
    }
    cout << ans << '\n';
    return;
}

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int qq;
    cin >> qq;
    while(qq--) {
        solve();
    }
    return 0;
}
