#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi2")

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <typename T>
using ordered_set = __gnu_pbds::tree <T, __gnu_pbds::null_type, less <T>,
        __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template <typename T>
int sz(const T &x) {
    return static_cast <int> (x.size());
}

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

const int MAXN = 2e5;
const ll INF = 4e18;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-8;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        vector <ll> x(m);
        for (auto& i : x) {
            cin >> i;
        }
        vector <vector <ll>> dp(m, vector <ll> (n + 1, -INF));
        dp[m - 1][n - 1] = x[m - 1];
        for (int suff = m - 2; suff >= 0; suff--) {
            for (int pluses = n - (m - suff) % 2; pluses >= max(0, n - (m - suff)); pluses -= 2) {
                if (pluses + 1 <= n) {
                    dp[suff][pluses] = max(dp[suff][pluses], dp[suff + 1][pluses + 1] + x[suff]);
                }
                if (0 <= pluses - 1) {
                    dp[suff][pluses] = max(dp[suff][pluses], dp[suff + 1][pluses - 1] - x[suff]);
                }
            }
        }
        cout << *max_element(dp[0].begin(), dp[0].end()) << '\n';
    }
    return 0;
}
