#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define int long long

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; ++i) {
        cin >> x[i];
    }
    vector<vector<int>> dp(m + 1, vector<int>(1 << n, -1e14));
    dp[m][(1 << n) - 1] = 0;
    for (int i = m - 1; i >= 0; --i) {
        for (int j = 0; j < 1 << n; ++j) {
            for (int k = 0; k < n; ++k) {
                if ((j >> k) & 1) {
                    dp[i][j] = max(dp[i][j], dp[i + 1][j ^ (1 << k)] - x[i]);
                } else {
                    dp[i][j] = max(dp[i][j], dp[i + 1][j ^ (1 << k)] + x[i]);
                }
            }
        }
    }
    int ans = -1e18;
    for (int i = 0; i < 1 << n; ++i) {
        ans = max(ans, dp[0][i]);
    }
    cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
