#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);

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;
	while (t--) {
		int n, m;
		cin >> n >> m;
		vector<int> x(m);
		cin >> x;
		vector<int> dp(5e4, -inf);
		dp[0 + 25000] = 0;
		for (int i = 0; i < m; ++i) {
			vector<int> dpp(5e4, -inf);
			for (int j = 0; j < 5e4; ++j) {
				if (dp[j] == -inf) {
					continue;
				}
				int a = j - 25000;
				int b = dp[j] - a;
				int aa = x[i] - a;
				int bb = x[i] - b;
				if (aa + 25000 < 5e4) {
					dpp[aa + 25000] = max(dpp[aa + 25000], aa + b);
				}
				dpp[a + 25000] = max(dpp[a + 25000], a + bb);
			}
			dp = dpp;
		}
		int ans = -inf;
		for (int j = 0; j < 5e4; ++j) {
			ans = max(ans, dp[j]);
		}
		cout << ans << "\n";
	}
	return 0;
}