#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

using ll = long long;
using ld = long double;

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

ll rand1(ll a, ll b) {
    return uniform_int_distribution<ll> (a, b) (gen);
}

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> x(m);
    for (auto &i : x) cin >> i;
    reverse(x.begin(), x.end());
    vector<vector<ll>> dp(m + 1, vector<ll> (n + 1, -1e18));
    dp[0][0] = 0;
    for (ll i = 1; i <= m; i++) {
        ll e = x[i - 1];
        for (ll j = 0; j <= n; j++) {
            if (j > 0) {
                dp[i][j] = max(dp[i - 1][j - 1] + e, dp[i][j]);
            }
            if (j < n) {
                dp[i][j] = max(dp[i - 1][j + 1] - e, dp[i][j]);
            }
        }
    }
    cout << *max_element(dp[m].begin(), dp[m].end());
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t12 = 1;
    cin >> t12;
    while (t12--) {
        solve();
        cout << '\n';
    }
    return 0;
}
