#include "bits/stdc++.h"
using namespace std;
# define int long long
# define all(a) a.begin(), a.end()

inline void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(auto &i : a) cin >> i;
    reverse(all(a));
    const int INF = 1e18;
    vector<vector<int>> dp(m + 1, vector<int>(1 << n, -INF));
    dp[0][0] = 0;
    for(int i = 1; i <= m; ++i){
        for(int mask = 0;  mask < (1 << n); ++mask){
            for(int j = 0; j < n; ++j){
                dp[i][mask ^ (1 << j)] = max(dp[i][mask ^ (1 << j)], dp[i - 1][mask] +  (((mask >> j) & 1) ? -a[i - 1] : a[i - 1]));
            }
        }
    }
    cout << *max_element(all(dp[m])) << '\n';
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    int aboba;
    cin >> aboba;
    while(aboba--){
        solve();
    }
    return 0;
}