#include <iostream>
#include <vector>
using namespace std;


const long long INF = 1e16;


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


int main() {
	long long t;
	cin >> t;
	for (long long i = 0; i < t; i++)
		solve();
}
