#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

const long long INF = 1e17;

void solve() {
    int n, m;
    cin >> m >> n;
    vector<long long> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    reverse(v.begin(), v.end());
    vector<vector<long long>> dp(n + 1, vector<long long>(m + 1, -INF));
    dp[0][m] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= m; j++) {
            if (dp[i][j] == -INF) {
                continue;
            }
            if (j > 0) {
                dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + v[i]);
            }
            if (j < m) {
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] - v[i]);
            }
        }
    }
    long long ans = -INF;
    for (int i = 0; i <= m; i++) {
        ans = max(ans, dp[n][i]);
    }
    cout << ans << '\n';
}

int main()
{
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        solve();
    }

    return 0;
}