#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <chrono>
using namespace std;
using ll = long long;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif;
    ll t;
    cin >> t;
    while (t--) {
        ll n, m;
        cin >> n >> m;
        vector<ll> a(m);
        ll sum = 0;
        for (int i = 0; i < m; ++i) {
            cin >> a[i];
        }
        vector<ll> dp(n + 1, -1e18), newdp(n + 1, -1e18);
        dp[n] = 0;
        for (int i = m - 1; i >= 0; --i) {
            for (int j = 0; j <= n; ++j) {
                if (j + 1 <= n)
                    newdp[j + 1] = max(newdp[j + 1], dp[j] - a[i]);
                if (j - 1 >= 0)
                    newdp[j - 1] = max(newdp[j - 1], dp[j] + a[i]);
            }
            swap(dp, newdp);
            fill(newdp.begin(), newdp.end(), -1e18);
        }
        ll ans = 0;
        for (auto el : dp)
            ans = max(ans, el);
        cout << ans << '\n';
    }
}