#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll

void solve() {
    int n, m;
    cin >> n >> m;
    multiset<int> tm;
    for (int i = 1; i <= n; i++)
        tm.insert(0);
    for (int i = 1, x; i <= m; i++) {
        cin >> x;
        int v = *tm.begin();
        tm.erase(tm.begin());
        tm.insert(x - v);
    }
    int ans = 0;
    for (auto &i : tm)
        ans += i;
    cout << ans << "\n";
}

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