//#pragma GCC optimize("O3");
//#pragma GCC target("avx, avx2")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define ALL(X) (X.begin()), (X.end())
#define sz(X) (int)(X.size())

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned int ui;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

const ll INF = 1e17;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	for (int i = 0; i < m; ++i) {
		cin >> x[i];
	}
	reverse(ALL(x));
	vector<vector<ll>> dp(m + 1, vector<ll>(n + 1, -INF));
	dp[0][n] = 0;
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j <= n; ++j) {
			if (dp[i][j] == -INF)
				continue;
			if (j > 0) {
				dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + x[i]);
			}
			if (j < n) {
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] - x[i]);
			}
		}
	}
	ll ans = -INF;
	for (int i = 0; i <= n; ++i) {
		ans = max(ans, dp[m][i]);
	}
	cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int t;
	cin >> t;
	while (t--) {
		solve();
	}    
    return 0;
}
