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

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<ll> dp(n + 1, 0);
	vector<ll> ndp(n + 1, -INF);
	for (auto i : arr) {
		ndp[0] = dp[1] - i;
		ndp[n] = dp[n - 1] + i;
		for (ll j = 1; j < n; j++) {
			ndp[j] = max(dp[j - 1] + i, dp[j + 1] - i);
		}
		swap(dp, ndp);
	}
	cout << dp.back() << '\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();
	}
}
