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

//#pragma GCC Optimize("O3")
//#pragma GCC Optimize("unroll-loops")
//#pragma GCC target("avx,avx2,bmi")

//using namespace __gnu_pbds;
using namespace std;

//template <class T> using ordered_set = tree<T, null_type, less<T> ,rb_tree_tag,tree_order_statistics_node_update>;
//struct h{
//    size_t operator ()(const pair<int,int>& a) const{
//        return ((size_t)a.first << 32) + a.second;
//    }
//};
void solve();

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

#define int long long
#define endl '\n'
const int INF = 2e18;
const int MAXN = 3e5+1;
const int MOD = 1e9 + 7;

void solve() {
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    vector<pair<int, vector<int>>>dp1((1 << n), {-INF, vector<int>(n, -INF)});
    dp1[0] = {0, vector<int>(n,0)};
    vector<pair<int, vector<int>>>dp2((1 << n), {-INF, vector<int>(n, -INF)});
    for (int i = 0; i< m;i++) {
        for (int mask = 0; mask < (1 << n); mask++) {
            if (dp1[mask].first<=-INF)continue;
            for (int j = 0; j < n; j++) {
                int nwmsk = mask ^ (1 << j);
                int was = dp1[mask].second[j];
                vector<int> nw = dp1[mask].second;
                nw[j]=was*-1+a[i];
                dp2[nwmsk] = max(dp2[nwmsk], {dp1[mask].first-was + was * -1 + a[i], nw});
            }
        }
        dp1 = dp2;
        dp2.assign((1 << n), {-INF, vector<int>(n, -INF)});
    }
    int ans = -INF;
    for (int i = 0; i < (1 << n); i++) {
        ans = max(ans, dp1[i].first);
    }
    cout << ans << endl;
}
