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

#define int long long
const int oo = 1e18;

bool get_bit(int x, int d) {
	return x >> d & 1;
}

void solution() {
	int n, m;
	cin >> n >> m;
	vector <int> x(m);
	for (int i = 0; i < m; i++) {
		cin >> x[i];
	}
	vector <vector <int>> dp(n + 1, vector <int>(m + 1, -oo));
	for (int mask = 0; mask <= n; mask++) {
		dp[mask][0] = 0;
	}
	for (int j = 0; j < m; j++) {
		for (int mask = 0; mask <= n; mask++) {
			if (mask > 0) {
				int nmask = mask - 1;
				dp[nmask][j + 1] = max(dp[nmask][j + 1], dp[mask][j] + x[j]);
			}
			if (mask < n) {
				int nmask = mask + 1;
				dp[nmask][j + 1] = max(dp[nmask][j + 1], dp[mask][j] - x[j]);
			}
		}
	}
	cout << dp[0][m];
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int t;
	cin >> t;
	while (t--) {
		solution();
		cout << '\n';
	}
}