#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];
    }
    ll ans = -INF;
    for (int mask = 0; mask < (1 << m); mask++) {
        ll sm = 0;
        ll c1 = 0, c2 = 0;
        for (int i = 0; i < m; i++) {
            if ((mask >> i) & 1) {
                sm += x[i];
                c2++;
            } else {
                sm -= x[i];
                c1++;
            }
        }
        if (c2 - c1 >= 0 && c2 - c1 <= n) {
            ans = max(ans, sm);
        }
    } 
    cout << ans << '\n';
} 