#include <bits/stdc++.h>

#ifndef  WILEYNE
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#endif

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using ordered_set = __gnu_pbds::tree<int, __gnu_pbds::null_type, std::less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;


using ll = long long;
using ld = long double;

using namespace std;

const int MAX_N = (int) 3e5 + 100;
const double eps = acos(-1);
const int INT_INF = (int) 2e9 + 10;
const int MOD = (int) 1e9 + 7;
auto seet = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(seet);

map<pair<vector<ll>, int>,bool>mp;
int x[MAX_N];
int n,m;
ll maxs = 0;
vector<ll>cur_res;
void dfs(int k){
    if(mp[{cur_res,k}]){
        return;
    }
    mp[{cur_res,k}] = true;
    if(k == m){
        ll sums = 0;
        for(auto c:cur_res){
            sums+=c;
        }
        maxs = max(maxs,sums);
        return;
    }
    for(int i = 0;i<n;++i){
        vector<ll>mem = cur_res;
        cur_res[i] = x[k] - cur_res[i];
        int ind = i;
        while(ind+1<n && cur_res[ind]>cur_res[ind+1]){
            swap(cur_res[ind],cur_res[ind+1]);
            ind++;
        }
        while(ind-1>=0 && cur_res[ind]<cur_res[ind-1]){
            swap(cur_res[ind],cur_res[ind-1]);
            ind--;
        }
        dfs(k+1);
        cur_res = mem;
    }
}

void solve(){

    cin>>n>>m;
    for(int i= 0;i<m;++i){
        cin>>x[i];
    }
    maxs = -1e18;
    cur_res.resize(n,0);
    dfs(0);
    cout<<maxs;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef WILEYNE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }

    return 0;
}
