#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> x(m);
    for(auto &y:x) cin>>y;
    vector<int> a(n);
    for(auto &y:x){
        int mn = 0;
        for(int j = 1; j < n; ++j){
            if (y - a[j] > y - a[mn]){
                mn = j;
            }
        }
        a[mn] = y - a[mn];
    }
    int ans = 0;
    for(auto &x:a) ans += x;
    cout<<ans<<'\n';
}

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