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


void solve() {
    ll n, m, inf = -1e9;
    cin >> n >> m;
    vector<ll> a(m + 1);
    for (int i = 1; i <= m; i++) {
        cin >> a[i];
    }
    vector<vector<ll>> dp(m + 1, vector<ll>(m + 1, inf));
    dp[0][0] = 0;
    for (ll i = m; i >= 1; i--) {
        for (ll j = 0; j <= m - i + 1; j++) {
            ll k = m - i + 1 - j;
            ll t = (j % 2 == 0 ? -a[i] : a[i]), p = (k % 2 == 0 ? -a[i] : a[i]);
            if (j >= 1) {
                dp[j][k] = max(dp[j][k], dp[j - 1][k] + t);
            }
            if (k >= 1) {
                dp[j][k] = max(dp[j][k], dp[j][k - 1] + p);
            }
        }
    }
    ll ans = inf;
    for (ll i = 0; i <= m; i++) {
        ans = max(ans, dp[i][m - i]);
    }
    cout << ans;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    freopen("input.txt", "r", stdin);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
