//#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 = 1e4;

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

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