#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll INF = 1e18;
int main() {
    ll t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        int n, m;
        cin >> n >> m;
        vector<ll> v(m);
        for (int i = 0; i < m; i++) {
            cin >> v[m - 1 - i];
        }
        vector<vector<ll>> dp(m, vector<ll>(n + 1, -INF));
        dp[0][n - 1] = v[0];
        for (int i = 1; i < m; i++) {
            for (int j = 0; j <= n; j++) {
                if (j != n) {
                    dp[i][j] = dp[i - 1][j + 1] + v[i];
                }
                if (j != 0) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] - v[i]);
                }
            }
        }
        ll mx = -INF;
        ll mxj = 0;
        for (int j = 0; j <= n; j++) {
            mx = max(mx, dp[m - 1][j]);
            if (mx == dp[m - 1][j]) {
                mxj = j;
            }
        }
        cout << mx << "\n";
    }
}