#include <string>
#include <bitset>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>

using namespace std;
using ll = long long;
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

void fast() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cout << setprecision(8) << fixed;
}

ll mod = 1e9 + 7;
ll binpow(ll a, ll n) {
    ll res = 1;
    for (int i = 0; (1ll << i) <= n; ++i, a = a * a % mod) {
        if ((n >> i) & 1) res = res * a % mod;
    }
    return res;
}

ll INF = -1e18;
void solve() {
    int n, m;
    cin >> n >> m;
    vector<ll> arr(m);
    for (auto &el : arr) cin >> el;
    vector<ll> dp(n + 1, INF);
    reverse(all(arr));
    dp[n - 1] = arr[0];
    for (int i = 1; i < m; ++i) {
        vector<ll> cur(n + 1, INF);
        for (int j = 0; j <= n; ++j) {
            if (j != 0 && dp[j - 1] != INF) {
                cur[j] = dp[j - 1] - arr[i];
            }
            if (j != n && dp[j + 1] != INF) {
                cur[j] = max(cur[j], dp[j + 1] + arr[i]);
            }
        }
        dp = cur;
    }
    ll ans = 0;
    for (int i = 0; i <= n; ++i) {
        ans = max(ans, dp[i]);
    }
    cout << ans << '\n';
}   
int main() {
    fast();
    int t = 1;
    cin >> t;
    while (t--) solve();
    return 0;
}