#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define db long double

using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int n, m, ans = LLONG_MIN; cin >> n >> m;

    vector<int> a(m);
    for (int i = 0; i < m; ++i) cin >> a[i];

    reverse(a.begin(), a.end());

    vector<vector<int>> dp(m + 1, vector<int>(n + 1, LLONG_MIN));
    dp[0][n] = 0;

    for (int i = 0; i < m; ++i) {
        int x = a[i];

        for (int j = 0; j <= n; ++j) {
            if (dp[i][j] == LLONG_MIN) continue;

            if (j + 1 <= n) {
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] - x);
            }

            if (j - 1 >= 0) {
                dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + x);
            }
        }
    }

    for (int i = 0; i <= n; ++i) {
        ans = max(ans, dp[m][i]);
    }

    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int tt; cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}