#include <bits/stdc++.h>

using namespace std;

void solve();

//#pragma GCC optimize("O3","Ofast","fastmath","unroll-loops")
//#pragma GCC target("avx2","sse4.2","bmi","lzcnt","popcnt")
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

#define int long long
#define endl '\n'
const int N = 200 + 1, INF = 2e9, MOD = 1e9 + 7;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m + 1);
    for (int i = 1; i <= m; i++) {
        cin >> x[i];
    }
    int ans = -INF;
    vector<vector<int>> dp(m + 1, vector<int>(n + 1, -INF));
    for(int k=0;k<=n;k++) {
        dp[0][k] = 0;
    }
    for (int i = 1; i <= m; i++) {
        for (int pls = 0; pls <= n; pls++) {
            if (pls - 1 >= 0) {
                dp[i][pls] = max(dp[i][pls], dp[i - 1][pls - 1] - x[i]);
            }
            if (pls + 1 <= n) {
                dp[i][pls] = max(dp[i][pls], dp[i - 1][pls + 1] + x[i]);
            }
        }
    }
    int cans = -INF;
    cans = max(cans, dp[m][0]);
    ans = max(ans, cans);

    cout << ans << endl;
}