#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <iomanip>

using namespace std;

long long t, n, m;
vector<long long> v1, dp1;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> t;

	for (long long h = 0; h < t; ++h) {
		cin >> n >> m;
		v1.clear();
		v1.resize(m);
		dp1.clear();
		dp1.resize(n + 1, -1e18);
		for (long long i = 0; i < m; ++i)
			cin >> v1[i];
		dp1[n] = 0;
		for (long long j = m - 1; j >= 0; --j) {
			vector<long long> dp2(n + 1, -1e18);
			for (long long i = 0; i <= n; ++i) {
				if (dp1[i] == -1e18)
					continue;
				if (i > 0)
					dp2[i - 1] = max(dp2[i - 1], dp1[i] + v1[j]);
				if (i < n)
					dp2[i + 1] = max(dp2[i + 1], dp1[i] - v1[j]);
			}
			dp1 = dp2;
		}
		long long ans = -1e18;
		for (long long i = 0; i <= n; ++i)
			ans = max(ans, dp1[i]);
		cout << ans << '\n';
	}

	return 0;
}
