#include <bits/stdc++.h>

using ll = long long;

using namespace std;

#define int ll

const int INF = LLONG_MAX / 2;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++) {
        cin >> x[m - i - 1];
    }
    vector<vector<int>> dp(2, vector<int> (2 * n + 1, -INF));

    auto get = [&dp, n](int i, int j) -> int& {
        return dp[i % 2][j + n];
    };

    get(0, n) = 0;

    for (int i = 0; i < m; i++) {
        for (int b = -n; b <= n; b++) {
            if (get(i, b) != -INF) {
                if (b + 2 <= n) {
                    get(i + 1, b + 2) = max(get(i + 1, b + 2), get(i, b) - x[i]);
                }
                if (b - 2 >= -n) {
                    get(i + 1, b - 2) = max(get(i + 1, b - 2), get(i, b) + x[i]);
                }
                get(i, b) = -INF;
            }
        }
    }
    int ans = -INF;
    for (int b = -n; b <= n; b++) {
        ans = max(ans, get(m, b));
    }
    cout << ans << "\n";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    cout << "\n";
    return 0;
}