#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll infll = 1e18;

template<typename T>
istream& operator>>(istream& is, vector<T>& a) {
	for (auto& i : a) {
		is >> i;
	}
	return is;
}

mt19937 rng(228);

int dp[401][100000];

int32_t main() {
#ifdef LOCAL
	assert(freopen("C:\\Users\\User\\input.txt", "r", stdin));
#else
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
#endif
	int t;
	cin >> t;
	for (int i = 0; i <= 400; ++i) {
		for (int j = 0; j < 1e5; ++j) {
			dp[i][j] = -inf;
		}
	}
	while (t--) {
		int n, m;
		cin >> n >> m;
		vector<int> x(m);
		cin >> x;
		dp[0][0 + 50000] = 0;
		for (int i = 0; i < m; ++i) {
			for (int j = 0; j < 1e5; ++j) {
				if (dp[i][j] == -inf) {
					continue;
				}
				int a = j - 50000;
				int b = dp[i][j] - a;
				int aa = x[i] - a;
				int bb = x[i] - b;
				dp[i + 1][aa + 50000] = max(dp[i + 1][aa + 50000], aa + b);
				dp[i + 1][a + 50000] = max(dp[i + 1][a + 50000], a + bb);
			}
		}
		int ans = -inf;
		for (int j = 0; j < 1e5; ++j) {
			ans = max(ans, dp[m][j]);
		}
		cout << ans << "\n";
		for (int i = 0; i <= m; ++i) {
			for (int j = 0; j < 1e5; ++j) {
				dp[i][j] = -inf;
			}
		}
	}
	return 0;
}