#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll c = ll(1e6) + 1;

vector<ll> x;

map<vector<ll>, ll> mapa;

ll f(ll i, ll k0, ll k1) {
    if (i == x.size()) return k0 + k1;
    if (mapa.find({i, k0, k1}) != mapa.end()) return mapa[{i, k0, k1}];
    ll ans = max(f(i + 1, x[i] - k0, k1), f(i + 1, k0, x[i] - k1));
    mapa[{i, k0, k1}] = ans;
    return ans;
}

void solve() {
    mapa.clear();
    ll n, m;
    cin >> n >> m;
    x.assign(m, 0);
    for (int i = 0; i < m; i++) cin >> x[i];
//    cout << f(0, 0, 0) << " mapa\n";
    vector<vector<vector<ll>>> dp(m, vector<vector<ll>>(m + 1, vector<ll>(m + 1, -inf)));
    dp[0][1][0] = x[0];
    dp[0][0][1] = -x[0];
    for (int i = 1; i < m; i++) {
        for (int j0 = 0; j0 <= m; j0++) {
            for (int j1 = 0; j1 <= m; j1++) {
                ll plus0 = 0, plus1 = 0;
                if (j0 % 2 == 0) {
                    plus0 += x[i];
                } else {
                    plus0 -= x[i];
                }
                if (j1 % 2 == 1) {
                    plus1 += x[i];
                } else {
                    plus1 -= x[i];
                }
                if (j0 < m) dp[i][j0 + 1][j1] = max(dp[i][j0 + 1][j1], dp[i - 1][j0][j1] + plus0);
                if (j1 < m) dp[i][j0][j1 + 1] = max(dp[i][j0][j1 + 1], dp[i - 1][j0][j1] + plus1);
            }
        }
    }
    ll ans = -inf;
    for (int i = 0; i < m + 1; i++) {
        for (int j = 0; j < m + 1; j++) {
            if (i != 0 && i % 2 == 0) continue;
            if (j != 0 && j % 2 == 1) continue;
            ans = max(ans, dp[m - 1][i][j]);
        }
    }
    for(int i = 0; i < m; i++) {
        ll res = 0, c1 = 0;
        if ((m - 1) % 2 == 1) {
            for (int j = 0; j < m; j++) {
                if (j == i) continue;
                c1++;
                if (c1 % 2 == 1) res += x[j];
                if (c1 % 2 == 0) res -= x[j];
            }
        } else {
            for (int j = 0; j < m; j++) {
                if (j == i) continue;
                c1++;
                if (c1 % 2 == 1) res -= x[j];
                if (c1 % 2 == 0) res += x[j];
            }
        }
        ans = max(ans, x[i] + res);
    }
    cout << ans << "\n";
}

int main() {
#ifdef KABANDJAN
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
