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

#pragma GCC optimize("O3")

using namespace std;
//using namespace __gnu_pbds;

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define int long long

//typedef tree<int, null_type,less<int>,  rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve(){
    int n, m;
    cin>>n>>m;
    vector<int> a(n);
    for(int i = 0; i < m; ++i){
        int x; cin>>x;
        int mn = 0;
        for(int j = 1; j < n; ++j){
            if (a[mn] > a[j]) mn = j;
        }
        a[mn] = x - a[mn];
    }
    int s = 0;
    for(auto &x:a) s += x;
    cout<<s<<'\n';
}

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