#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <array>
#include <queue>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) a.begin(), a.end()
const ll INF = 1e18;
void solve() {
	ll n, m;
	cin >> n >> m;
	vector<ll> x(m);
	for (ll i = 0; i < m; i++) {
		cin >> x[i];
	}
	vector<ll> dp(n + 1, -INF), ndp(n + 1, -INF);
	dp[n] = 0;
	for (ll i = m - 1; i >= 0; i--) {
		for (ll j = 0; j <= n; j++) {
			ndp[j] = -INF;
			if (j < n) ndp[j] = max(ndp[j], dp[j + 1] + x[i]);
			if (j > 0) ndp[j] = max(ndp[j], dp[j - 1] - x[i]);
		}
		dp.swap(ndp);
	}
	cout << *max_element(all(dp)) << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}