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

#define int long long

using namespace std;

int l = 2000;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	vector<vector<int>>used(3 * l, vector<int>(3 * l, -1));
	for (; t > 0; --t) {
		int n, m;
		cin >> n >> m;
		vector<pair<int, int>>ans1;

		
		ans1.push_back({ 0,0 });
		vector<pair<int, int>>ans2;
		for (int i = 0; i < m; ++i) {
			int a;
			cin >> a;
			ans2.clear();
			for (pair<int, int>x : ans1) {
				if (used[a - x.first + l][x.second+l] != i+t*l) {
					ans2.push_back({ a - x.first,x.second });
					used[a - x.first + l][x.second+l] = i+t*l;
				}
				if (used[x.first + l][a - x.second + l] != i + t * l) {
					ans2.push_back({ x.first,a - x.second });
					used[x.first + l][a - x.second + l] = i + t * l;
				}
			}
			ans1 = ans2;
		}
		int ans = 0;
		for (pair<int, int>x : ans1) {
			ans = max(ans, x.first + x.second);
		}
		cout << ans << '\n';
	}
	return 0;
}