#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m);
    for (ll i = 0; i < m; i++) {
        cin >> a[i];
    }
    ll sum = 0;
    multiset<ll> ms;
    for (ll i = 0; i < n; i++) ms.insert(0);
    for (ll i : a) {
        ll x = *ms.begin();
        sum -= x;
        sum += i - x;
        ms.erase(ms.find(x));
        ms.insert(i - x);
    }
    cout << sum << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll tt = 1;
    cin >> tt;
    while (tt--) {
        solve();
    }
}
