#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define endl "\n"
#define ff first
#define ss second
#define ordered_set tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>
#define all(x) x.begin(), x.end()

const int INF = 1e18;

void solve() {

    int n, m;
    cin >> n >> m;

    n = min(n, m);

    vector<int> a(m, 0);

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

    reverse(all(a));

    vector<vector<int>> dp(m + 1, vector<int>(n + 1, -INF));

    dp[0][n] = 0;

    for (int i = 0; i < m; i++) {
        for (int chet = 0; chet <= n; chet++) {
            if (dp[i][chet] == -INF) {
                continue;
            }
            if (chet > 0) {
                dp[i + 1][chet - 1] = max(dp[i + 1][chet - 1], dp[i][chet] + a[i]);
            }
            if (chet < n) {
                dp[i + 1][chet + 1] = max(dp[i + 1][chet + 1], dp[i][chet] - a[i]);
            }
        }
    }

    int ans = 0;

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

    cout << ans << endl;

}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int TN;
    cin >> TN;

    while (TN--) {
        solve();
    }

}
