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

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O3,unroll-loops")
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using str = string;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const ll INF = 1e18, MOD = 1e9 + 7;
#define int long long

void solve();

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
        cout << "\n";
    }
}


void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m + 1);
    for (int i = 0; i < m; ++i) {
        cin >> a[i + 1];
    }
    vector<vector<int>> dp(m + 1, vector<int>(n + 1));
    for (int i = 1; i <= m; ++i) {
        for (int j = max(n - 100ll, 0ll); j <= n; ++j) {
            if (j == 0) {
                dp[i][j] = dp[i - 1][j + 1] - a[i];
            } else if (j == n) {
                dp[i][j] = dp[i - 1][j - 1] + a[i];
            } else {
                dp[i][j] = max(dp[i - 1][j + 1] - a[i], dp[i - 1][j - 1] + a[i]);
            }
        }
    }
    cout << dp[m][n];
}