#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//using ll = int;
using ld = long double;
using ull = unsigned long long;
#define pb push_back
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
#ifdef LOCAL
#define deb(x) cout << #x << " = " << x << '\n'
#else
#define deb(x) 52
#endif
const ll inf = 1e9 + 11;
const long long INF = (long long)2e18 + 11;
const ll P = 73;
const ll MOD = 1e9 + 7;


void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> x(m);
    for (ll i = 0; i < m; ++i) {
        cin >> x[i];
    }
    reverse(all(x));
    ll ans = 0;
    auto upd_ans = [&](ll mask) -> void {
        ll bal = 0;
        ll cur = 0;
        for (ll i = 0; i < m; ++i) {
            if (1 & (mask >> i)) {
                ++bal;
                if (bal > n) {
                    return;
                }
                cur += x[i];
            } else {
                --bal;
                if (bal < 0) {
                    return;
                }
                cur -= x[i];
            }
        }
        ans = max(ans, cur);
    };
    for (ll mask = 0; mask < (1 << m); ++mask) {
        upd_ans(mask);
    }
    cout << ans;
}


int main() {
#ifdef LOCAL
    freopen("C:/work/untitled/input.txt", "r", stdin);
    freopen("C:/work/untitled/output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll cfmode = 1;
    ll tc = 1;
    if (cfmode) {
        cin >> tc;
    }
    while (tc--) {
        solve();
        if (tc) {
            cout << '\n';
        }
    }
}