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

ll get_ans(vector <ll> &a) {
    vector <vector <ll>> dp(2, vector <ll>(n + 1, -inf));
    dp[0][n] = 0;
    for (int j = 0; j < m; j++) {
        for (int bal = 0; bal <= n; bal++) {
            if (dp[0][bal] == -inf) continue;
            if (bal + 1 <= n) {
                dp[0 + 1][bal + 1] = max(dp[0 + 1][bal + 1], dp[0][bal] - a[j]);
            }
            if (bal - 1 > -1) {
                dp[0 + 1][bal - 1] = max(dp[0 + 1][bal - 1], dp[0][bal] + a[j]);
            }
        }
        swap(dp[0], dp[1]);
        dp[1].assign(n + 1, -inf);
    }
    ll ans = -inf;
    for (int i = 0; i <= n; i++) ans = max(ans, dp[0][i]);
    return ans;
}
const int C = 2e3;

void solve() {
    cin >> n >> m;
    n = min(n, C);
    vector <ll> a(m, 0);
    for (int i = 0; i < m; i++) cin >> a[i];
    reverse(a.begin(), a.end());
    ll ans = get_ans(a);
    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();
    }
}
