#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (auto &a : x) cin >> a;
    vector<ll> dp(n + 1, 0), dp2(n + 1, LLONG_MIN);
    for (int i = 0; i < m; ++i) {
        for (int ost = 0; ost <= n; ++ost) {
            if (ost + 1 <= n && dp[ost + 1] != LLONG_MIN) dp2[ost] = max(dp2[ost], dp[ost + 1] + x[i]);
            if (ost - 1 >= 0 && dp[ost - 1] != LLONG_MIN) dp2[ost] = max(dp2[ost], dp[ost - 1] - x[i]);
        }
        dp = dp2;
        dp2.assign(n + 1, LLONG_MIN);
    }
    cout << dp[0] << '\n';
}

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