#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define vi vector<ll>
#define vii vector<vi>
#define vip vector<pair<ll, ll>>
#define viip vector<vip>
#define endl '\n'
#define pb push_back
#define all(a) a.begin(), a.end()

ll INF = 1e9;

void solve() {
    ll n, m;
    cin >> n >> m;
    vi a(n);
    vi x(m);
    for (ll i = 0; i < m; i++) {
        cin >> x[i];
    }
    set<vi> dp;
    vi gg;
    for (ll i = 0; i < n; i++) {
        gg.pb(0);
    }
    dp.insert(gg);
    for (ll i = 0; i < m; i++) {
//        vip val;
//        ll mx = -INF;
//        for (auto [c, d] : dp) {
//            if (mx > d) {
//                val.pb({c, d});
//            }
//            mx = max(mx, d);
//        }
//        for (auto [c, d] : val) {
//            dp.erase({c, d});
//        }

        set<vi> ndp;
        for (auto e : dp) {
            for (ll j = 0; j < n; j++) {
                auto y = e;
                ll f = y[j];
                y[j] = x[i] - f;
                sort(all(y));
                ndp.insert(y);
                y[j] = f;
            }
        }
        swap(dp, ndp);
    }
    ll ans = -INF;
    for (auto e : dp) {
        ll c = 0;
        for (ll i = 0; i < n; i++) {
            c += e[i];
        }
        ans = max(ans, c);
    }
    cout << ans << endl;
}

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