#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) static_cast<lng>(x.size())

using lng = long long;

struct SegTree {
	int left, right;
	lng min_elem, max_elem, added;
	SegTree* lv, * rv;
	SegTree(int l = 0, int r = 1) : left(l), right(r), min_elem(0), max_elem(0), added(0), lv(nullptr), rv(nullptr) {
		if (l + 1 != r) {
			int m = (l + r) / 2;
			lv = new SegTree(l, m);
			rv = new SegTree(m, r);
		}
	}
	void push() {
		lv->added += added;
		rv->added += added;
		lv->max_elem += added;
		lv->min_elem += added;
		rv->max_elem += added;
		rv->min_elem += added;
		added = 0;
	}
	void add(int qleft, int qright, lng x) {
		if (qleft <= left && right <= qright) {
			added += x;
			min_elem += x;
			max_elem += x;
			return;
		}
		if (qright <= left || right <= qleft) {
			return;
		}
		if (added != 0) {
			push();
		}
		lv->add(qleft, qright, x);
		rv->add(qleft, qright, x);
		min_elem = min(lv->min_elem, rv->min_elem);
		max_elem = max(lv->max_elem, rv->max_elem);
	}
	lng get_min(int qleft, int qright) {
		if (qleft <= left && right <= qright) {
			return min_elem;
		}
		if (qright <= left || right <= qleft) {
			return 1e18;
		}
		if (added != 0) {
			push();
		}
		return min(lv->get_min(qleft, qright), rv->get_min(qleft, qright));
	}
	lng get_max(int qleft, int qright) {
		if (qleft <= left && right <= qright) {
			return max_elem;
		}
		if (qright <= left || right <= qleft) {
			return -1e18;
		}
		if (added != 0) {
			push();
		}
		return max(lv->get_max(qleft, qright), rv->get_max(qleft, qright));
	}
};

void solve() {
	int n, m; cin >> n >> m;
	vector<lng> x(m);
	for (lng& i : x) {
		cin >> i;
	}
	reverse(all(x));
	vector<vector<lng>> dp(m + 1, vector<lng>(n + 1, -1e18));
	dp[0][n] = 0;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j <= n; j++) {
			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]);
			}
		}
	}
	cout << *max_element(all(dp[m])) << '\n';
}

int main() { 
	cin.tie(nullptr)->sync_with_stdio(false);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
