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

#define int long long
using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
struct fenw {
    vector<int> f;
    explicit fenw(int n) {
        f.resize(n);
    }
    void upd(int i, int x) {
        while (i < f.size()) {
            f[i] += x;
            i |= (i + 1);
        }
    }
    int get(int i) {
        int sum = 0;
        while (i >= 0) {
            sum += f[i];
            i %= (i + 1);
            i--;
        }
        return sum;
    }
};
template <typename T>
bool smin(T& a, T b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool smax(T& a, T b) {
    if (b > a) {
        a = b;
        return true;
    }
    return false;
}
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, -1e18));
    dp[0] = vector<int> (1 << n, 0);
    for (int i = 0; i < m; i++) {
        for (int mask = 0; mask < (1 << n); mask++) {
            for (int j = 0; j < n; j++) {
                if ((mask >> j) & 1) {
                    smax(dp[i + 1][mask], dp[i][mask - (1 << j)] - x[i]);
                } else {
                    smax(dp[i + 1][mask], dp[i][mask + (1 << j)] + x[i]);
                }
            }
        }
    }
    cout << dp[m][0] << '\n';
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
