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

using namespace std;
using namespace __gnu_pbds;

#define int long long

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    vector<vector<int>> dp(m + 1, vector<int>(n + 1, -1e9));
    dp[m][n] = 0;
    for (int i = m - 1;i > -1; i--) {
        for (int j = 0; j <= n; j++) {
            if (j < n) {
                dp[i][j] = max(dp[i][j], a[i] + dp[i + 1][j + 1]);
            }
            if (j > 0) {
                dp[i][j] = max(-a[i] + dp[i + 1][j - 1], dp[i][j]);
            }
        }
    }
    int mx = 0;
    for (auto el : dp[0]) {
        mx = max(mx, el);
    }
    cout << mx << "\n";
}

signed main() {
    int t;
    cin >> t;
    while (t--) solve();
}
