#include<iostream>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<random>
#include<algorithm>
#include<chrono>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define int long long

const int INF = 1e18;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    reverse(x.begin(), x.end());
    vector<vector<int>> dp(m + 1, vector<int>(n + 1, -INF));
    dp[0][0] = 0;
    for (int i = 1; i <= m; i++) {
        // if (i < )
        for (int j = 0 + max(0ll, (i > 300) * (n - 300)); j <= n; j++) {
            if (j != 0) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + x[i - 1]);
            }
            if (j != n) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j + 1] - x[i - 1]);
            }
        }
    }
    int ans = -INF;
    for (int i = 0; i <= n; i++) {
        ans = max(ans, dp[m][i]);
    }
    cout << ans << '\n';
}
signed main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    cout.precision(20);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}