#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
using ll = long long;
using ld = long double;
const ll INF = 1e18;


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

	int t; cin >> t;
	for (int _ = 0; _ < t; ++_) {
		int n, m;
		cin >> n >> m;
		vector<ll> x(m + 1);
		for (int i = 1; i <= m; ++i)
			cin >> x[i];
		reverse(x.begin(), x.end());
		vector<vector<ll>> dp(m + 1, vector<ll>(n + 1, -INF));
		dp[0][n] = 0;
		for (int i = 0; i < m; ++i) {
			for (int j = 0; j <= n; ++j) {
				if (dp[i][j] == -INF) continue;
				if (j != 0)
					dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + x[i]);
				if (j != n)
					dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] - x[i]);
			}
		}
		ll ans = -INF;
		for (int j = 0; j <= n; ++j) {
			ans = max(ans, dp[m][j]);
		}
		cout << ans << "\n";
	}

	return 0;
}