#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <bitset>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define for0(i, n) for (ll i = 0; i < n; ++i)
#define for1(i, n) for (ll i = 1; i <= n; ++i)
#define fora(i, v) for (auto i : v)
#define ft first
#define sd second
#define pk push_back
#define pok pop_back
#define ret return
#define con continue
#define sz(v) v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using ll = long long;
using pll = pair <ll, ll>;
using vll = vector <ll>;
using vpll = vector <pll>;
using vvll = vector <vll>;
using pi = pair <int, int>;
using vi = vector <int>;
using vpi = vector <pi>;
using vvi = vector <vector <int>>;

const ll N = 500, inf = 1e18;

ll t, n, m, g, z, l, a, k, ans;
bitset <2 * N> b[2 * N], bn[2 * N];
pll res;
vll v;

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> t;
	while (t--) {
		cin >> n >> m;
		g = 0; z = 0; l = 0; ans = -inf;
		v.assign(m, 0); b[N][N] = 1;
		for0(q, m) {
			cin >> a;
			for0(i, 2 * N) {
				for0(j, 2 * N) {
					if (b[i][j]) {
						bn[a - i + 2 * N][j] = 1;
						bn[i][a - j + 2 * N] = 1;
					}
				}
			}
			for0(i, 2 * N)
				b[i] = bn[i];
		}

		for0(i, 2 * N) {
			for0(j, 2 * N) {
				if (b[i][j])
					ans = max(ans, i + j - 2 * N);
			}
		}
		cout << ans << "\n";
		for0(i, 2 * N)
			b[i].reset();
	}
	ret 0;
}