#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll q = 1;
    cin >> q;
    while (q--) {
        solve();
    }
}

const ll INF = 1e18;

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> x(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    reverse(x.begin(), x.end());
    ll ans = -INF;
    for (int mask = 0; mask < (1 << m); mask++) {
        ll sm = 0;
        ll c = 0;
        bool fl = true;
        for (int i = 0; i < m; i++) {
            if ((mask >> i) & 1) {
                sm += x[i];
            } else {
                sm -= x[i];
                c++;
            }
            if (2 * c < i + 1 - n || 2 * c > i + 1) {
                fl = false;
            }
        }
        if (fl) {
            ans = max(ans, sm);
        }
    } 
    cout << ans << '\n';
} 