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

//#define int long long

using namespace std;

int32_t main() {
	int t;
	cin >> t;
	for (; t > 0; --t) {
		int n, m;
		cin >> n >> m;
		set<pair<int, int>>ans1;
		ans1.insert({ 0,0 });
		set<pair<int, int>>ans2;
		for (int i = 0; i < m; ++i) {
			int a;
			cin >> a;
			ans2.clear();
			for (pair<int, int>x : ans1) {
				ans2.insert({ a - x.first,x.second });
				ans2.insert({ x.first,a - x.second });
			}
			ans1 = ans2;
		}
		int ans = 0;
		for (pair<int, int>x : ans1) {
			ans = max(ans, x.first + x.second);
		}
		cout << ans << '\n';
	}
	return 0;
}