#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define vi vector<ll>
#define vii vector<vi>
#define vip vector<pair<ll, ll>>
#define viip vector<vip>
#define endl '\n'
#define pb push_back
#define all(a) a.begin(), a.end()

ll INF = 1e9;

void solve() {
     ll n, m;
     cin >> n >> m;
     vi a(n);
     vi x(m);
     for (ll i = 0; i < m; i++) {
         cin >> x[i];
         ll mx = -INF, id = 0;
         for (ll j = 0; j < n; j++) {
             if (x[i] - 2 * a[j] > mx) {
                 mx = x[i] - 2 * a[j];
                 id = j;
             }
         }
         a[id] = x[i] - a[id];
     }
     ll ans = 0;
     for (ll i = 0; i < n; i++) {
         ans += a[i];
     }
     cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}
