#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(x) x.begin(), x.end()
#define ff first
#define ss second

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using pii = pair<int, int>;

ll n, m;
vector<ll> cur;
vector<ll> x;
ll ans;

void f(ll i) {
    if (i == m) {
        ll cand = 0;
        for (ll val : cur) {
            cand += val;
        }
        ans = max(ans, cand);
        return;
    }
    for (ll j = 0; j < n; ++j) {
        cur[j] = x[i] - cur[j];
        f(i + 1);
        cur[j] = x[i] - cur[j];
    }
}

void solve() {
    cin >> n >> m;
    cur.clear();
    cur.resize(n);
    x.clear();
    x.resize(m);
    ans = LLONG_MIN;
    for (ll i = 0; i < m; ++i) {
        cin >> x[i];
    }
    f(0);   
    cout << ans << endl;
}

signed main() {
    // freopen("inputb.txt", "r", stdin);
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
}
