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

using namespace std;
using namespace __gnu_pbds;

#define int long long

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)((x).size()))

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

const ll INF = 3e18;

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

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; ++i) {
        cin >> x[i];
    }
    reverse(all(x));
    dp[n] = 0;
    for (int i = 0; i < m; ++i) {
        vector<int> ndp(n + 1, -INF);
        for (int j = 0; j <= n; ++j) {
            if (j) {
                ndp[j - 1] = max(ndp[j - 1], dp[j] + x[i]);
            }
            if (j != n) {
                ndp[j + 1] = max(ndp[j + 1], dp[j] - x[i]);
            }
        }
        dp.swap(ndp);
    }
    cout << *max_element(all(dp)) << '\n';
}

signed main() {
#ifdef LOCALEGOR
    freopen("INPUT.txt", "r", stdin);
#else
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
    int tt = 1;
    cin >> tt;
    while (tt--) {
        solve();
    }
}