#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi2")

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <typename T>
using ordered_set = __gnu_pbds::tree <T, __gnu_pbds::null_type, less <T>,
        __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template <typename T>
int sz(const T &x) {
    return static_cast <int> (x.size());
}

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

const int MAXN = 2e5;
const int INF = 2e9;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-8;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        multiset <ll> minimums;
        for (int i = 0; i < n; i++) {
            minimums.insert(0);
        }
        for (int i = 0; i < m; i++) {
            ll x;
            cin >> x;
            ll minimum = *minimums.begin();
            minimum = x - minimum;
            minimums.erase(minimums.begin());
            minimums.insert(minimum);
        }
        ll ans = 0;
        for (auto i : minimums) {
            ans += i;
        }
        cout << ans << '\n';
    }
    return 0;
}
