#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define int long long

const int MAX = 2e3 + 7;

int dp[MAX][MAX];

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m + 1);
    for (int i = 1; i <= m; i++) {
        cin >> a[i];
    }
    for (int i = 0; i <= m; i++) {
        for (int j = 0; j <= n * 2; j++) {
            dp[i][j] = -1e18;
        }
    }
    dp[0][n] = 0;
    for (int i = 1; i <= m; i++) {
        for (int bal = 0; bal <= n * 2; bal++) {
            if (bal - 1 >= 0) {
                dp[i][bal] = max(dp[i][bal], dp[i - 1][bal - 1] + a[i]);
            }
            if (bal + 1 <= n * 2) {
                dp[i][bal] = max(dp[i][bal], dp[i - 1][bal + 1] - a[i]);
            }
        }
    }
    cout << *max_element(dp[m - 1], dp[m - 1] + n * 2) + a[m] << '\n';
}

int32_t main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tt = 1;
     cin >> tt;
    while (tt--) {
        solve();
    }
}