#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
using ll = long long;
using ld = long double;

#define int long long

int n, m;
vector<int> x;

void solve() {
	cin >> n >> m;
	x.resize(m);
	for (int i = 0; i < m; ++i) {
		cin >> x[i];
	}
	vector<pair<int, int>> dp;
	dp.insepush_backrt({0, 0});
	for (int i = 0; i < m; ++i) {
		vector<pair<int, int>> new_dp;
		for (auto it : dp) {
			new_dp.push_back({x[i] - it.first, it.second});
			new_dp.push_back({it.first, x[i] - it.second});
		}
		dp.swap(new_dp);
		sort(dp.begin(), dp.end());
		dp.erase(unique(dp.begin(), dp.end()), dp.end());
	}
	int ans = -1e18;
	for (auto it : dp) ans = std::max(ans, it.first + it.second);
	cout << ans << '\n';
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	int tests;
	cin >> tests;
	while (tests--) {
		solve();
	}
}
