#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

// #define FILE
#define int long long

const int INF = 1e18;

void solve() {
    int n, m;
    cin >> n >> m;
    n++;
    vector<int> a(m);
    for (int i = 0; i < m; ++i) cin >> a[i];
    reverse(a.begin(), a.end());
    vector<int> dp(n, -INF), new_dp(n);
    dp[0] = 0;
    for (auto x : a) {
        fill(new_dp.begin(), new_dp.end(), -INF);
        for (int i = 0; i < n; ++i) {
            if (i != 0 && dp[i - 1] != -INF && dp[i - 1] + x > new_dp[i]) {
                new_dp[i] = dp[i - 1] + x;
            } 
            if (i != n - 1 && dp[i + 1] != -INF && dp[i + 1] - x > new_dp[i]) {
                new_dp[i] = dp[i + 1] - x;
            }
        }
        swap(dp, new_dp);
    }
    int ans = -INF;
    for (auto x : dp) {
        ans = max(x, ans);
    }
    cout << ans << '\n';
}


signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}