#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll inf = 1e18 + 10ll;

void solve() {
    int n, m; cin >> n >> m;
    vector <ll> a(m, 0);
    for (int i = 0; i < m; i++) cin >> a[i];
    vector <vector <ll>> dp(m + 1, vector <ll>(n + 1, -inf));
    dp[0][n] = 0;
    reverse(a.begin(), a.end());
    for (int j = 0; j < m; j++) {
        for (int bal = 0; bal <= n; bal++) {
            if (dp[j][bal] == -inf) continue;
            if (bal + 1 <= n) {
                dp[j + 1][bal + 1] = max(dp[j + 1][bal + 1], dp[j][bal] - a[j]);
            }
            if (bal - 1 > -1) {
                dp[j + 1][bal - 1] = max(dp[j + 1][bal - 1], dp[j][bal] + a[j]);
            }
        }
    }
    ll ans = 0ll;
    for (int i = 0; i <= n; i++) {
        ans = max(ans, dp[m][i]);
    }
    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test = 1;
    cin >> test;
    for (int i = 0; i < test; i++) {
        solve();
    }
}
