#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#pragma GCC target("avx2")

using namespace std;

#define int long long

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> X(m); for (auto &e : X) cin >> e; reverse(X.begin(), X.end());
    vector<vector<int>> dp(m + 1, vector<int>(n + 1, -1e15));
    // for (auto &e : dp[0]) e = 0;
    dp[0][n] = 0;
    int i = 0;
    for (auto x : X) {
        for (int j = 0; j <= n; ++j) {
            if (j < n) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] - x);
            if (j > 0) dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + x);
        }
        ++i;
    }
    cout << *max_element(dp[m].begin(), dp[m].end()) << '\n';
}

signed main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int tc;
    cin >> tc;
    while (tc--) solve();
}