//#pragma GCC optimize("O3, unroll_loops")
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#define int long long

using namespace std;

const int INF = 2e15, CNST = 1e5;

void solve() {
	int n, m;
	cin >> n >> m;
	vector <int> brr(m);
	for (int i = 0; i < m; i++) {
		cin >> brr[i];
	}
	vector <vector <int>> dp1(m, vector <int> (2 * CNST + 1, -INF)), dp2(m, vector <int> (2 * CNST + 1, INF));
	dp1[0][0 + CNST] = brr[0];
	dp2[0][0 + CNST] = brr[0];
	dp1[0][brr[0] + CNST] = 0;
	dp2[0][brr[0] + CNST] = 0;
	for (int i = 0; i < m - 1; i++) {
		for (int a = -CNST; a <= CNST; a++) {
			if (dp2[i][a + CNST] != INF) {
				dp1[i + 1][a + CNST] = max(dp1[i + 1][a + CNST], brr[i + 1] - dp2[i][a + CNST]);
				dp2[i + 1][brr[i + 1] - a + CNST] = min(dp2[i + 1][brr[i + 1] - a + CNST], dp2[i][a + CNST]);
			}
			if (dp1[i][a + CNST] != -INF) {
				dp1[i + 1][brr[i + 1] - a + CNST] = max(dp1[i + 1][brr[i + 1] - a + CNST], dp1[i][a + CNST]);
				dp2[i + 1][a + CNST] = min(dp2[i + 1][a + CNST], brr[i + 1] - dp1[i][a + CNST]);
			}
		}
	}
	int ans = -INF;
	for (int a = -CNST; a <= CNST; a++) {
		ans = max(ans, dp1[m - 1][a + CNST] + a);
	}
	cout << ans << '\n';
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t;
	cin >> t;
	while (t--) {
		solve();
	}
}
