#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 1'000'000'000'000'000'000;

template<typename T>
bool assign_max(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
bool assign_min(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

void solve() {
	ll n, m;
	cin >> n >> m;
	vector<ll> arr(m);
	for (ll i = 0; i < m; i++) {
		cin >> arr[i];
	}
	vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, -INF));
	for (ll i = 0; i <= n; i++) {
		dp[0][i] = 0;
	}
	for (auto i : arr) {
		vector<vector<ll>> ndp(n + 1, vector<ll>(n + 1, -INF));
		for (ll cp = 0; cp <= n; cp++) {
			for (ll co = 0; co <= n; co++) {
				if (dp[cp][co] != -INF) {
					if (cp > 0) {
						assign_max(ndp[cp - 1][co + 1], dp[cp][co] + i);
					}
					if (co > 0) {
						assign_max(ndp[cp + 1][co - 1], dp[cp][co] - i);
					}
					if (co + cp < n) {
						assign_max(ndp[cp][co + 1], dp[cp][co] + i);
					}
				}
			}
		}
		dp = ndp;
	}
	ll ans = -INF;
	for (ll i = 0; i <= n; i++) {
		assign_max(ans, dp[0][i]);
	}
	cout << ans << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t;
	cin >> t;
	for (ll i = 0; i < t; i++) {
		solve();
	}
}
