#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <ctime>
#include <chrono>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <deque>
#include <bitset>
using namespace std;
mt19937_64 rnd(time(NULL));

const long long INF = 1e18, MOD = 1e9 + 7;

void solve()
{
	long long k, n;
	vector<long long> v;
	cin >> k >> n;
	v.resize(n);
	for (long long i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	reverse(v.begin(), v.end());

	vector<long long> dp(k + 1, -INF);
	dp[k] = 0;
	for (long long i = 0; i < n; i++)
	{
		vector<long long> nxt(k + 1, -INF);
		for (long long j = 0; j < k + 1; j++)
		{
			if (j)
			{
				nxt[j - 1] = max(nxt[j - 1], dp[j] + v[i]);
			}
			if (j < k)
			{
				nxt[j + 1] = max(nxt[j + 1], dp[j] - v[i]);
			}
		}
		swap(dp, nxt);
	}
	cout << *max_element(dp.begin(), dp.end()) << "\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}

/*

























*/
