#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll N = 3e5 + 5;

ll x[N];

void solve() {
    ll n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> x[i];
    }
    if (n == 1) {
        ll ans = 0;
        for (int i = m; i >= 1; --i) {
            if ((m - i) % 2 == 0) {
                ans += x[i];
            } else {
                ans -= x[i];
            }
        }
        cout << ans << '\n';
        return;
    }
    ll gg = n;
    ll E = 500;
    unordered_map<ll, ll> dp;
    dp[n] = 0;
    for (int i = m; i >= 1; --i) {
        gg--;
        unordered_map<ll, ll> dp1;
        for (int j = max((ll) 0, gg - E - 2); j <= min(n, gg + E + 2); ++j) {
            dp1[j] = (ll) -1e18;
        }
        for (int j = max((ll) 0, gg - E); j <= min(n, gg + E); ++j) {
            if (dp.count(j)) {
                dp1[j + 1] = max(dp1[j + 1], dp[j] - x[i]);
                if (j)dp1[j - 1] = max(dp1[j - 1], dp[j] + x[i]);
            }
        }
        swap(dp, dp1);
    }
    ll ans = (ll) -1e18;
    for (auto [a, b]: dp) {
        ans = max(ans, b);
    }
    cout << ans << '\n';
}

int main() {
    int test = 1;
    cin >> test;
    while (test--) {
        solve();
    }
}