#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using li = __int128;
using db = double;
using ld = long double;
using pi = pair <int, int>;
using pll = pair <ll, ll>;
#define all(x) x.begin(), x.end()

const ll INFll = 3e14;

mt19937 rnd(time(NULL));

struct V {
    db x;
    db y;
};

V operator+ (const V& a, const V& b) {
    return {a.x + b.x, a.y + b.y};
}
db operator* (const V& a, const V& b) {
    return a.x * b.x + a.y * b.y;
}
db operator^ (const V& a, const V& b) {
    return a.x * b.y - a.y * b.x;
}
V operator* (const V& a, db k) {
    return {a.x * k, a.y * k};
}

ll bin_pow(ll a, ll s, ll mod) {
    ll res = 1;
    while (s) {
        if (s & 1) {
            res *= a;
            res %= mod;
        }
        a = (a * a) % mod;
        s >>= 1;
    }
    return res;
}


void solve() {
    int n, m;
    cin >> n >> m;
    vector <ll> v(m);
    for (auto& i : v) cin >> i;
    reverse(all(v));
    vector <ll> dp(n + 1, -INFll);
    dp[1] = v[0];
    for (int i = 1; i < m; ++i) {
        vector <ll> nw(n + 1, -INFll);
        if ((i + 1) % 2 == 0) nw[0] = dp[1] - v[i];
        if (n % 2 == (i + 1) % 2 && n <= i + 1) nw[n] = dp[n - 1] + v[i];
        for (int j = 1; j < n && j <= i + 1; ++j) {
            if (j % 2 == (i + 1) % 2) {
                if (j + 1 <= i) nw[j] = max(dp[j - 1] + v[i], dp[j + 1] - v[i]);
                else nw[j] = dp[j - 1] + v[i];
            }
        }
        dp = nw;
    }
    ll ans = 0;
    for (auto el : dp) ans = max(ans, el);
    cout << ans << '\n';
}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while (t--) solve();
    return 0;
}
