#ifndef LOCAL
  // #pragma GCC optimize("Ofast,unroll-loops")
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef LOCAL
  // #pragma GCC target("avx,avx2,fma")
#endif

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

void solve() {
  int n, m;
  cin >> n >> m;
  multiset<ll> a;
  for (int i = 0; i < n; ++i) {
    a.insert(0);
  }
  for (int i = 0; i < m; ++i) {
    ll x;
    cin >> x;
    ll y = *a.begin();
    a.extract(y);
    y = x - y;
    a.insert(y);
  }
  cout << accumulate(a.begin(), a.end(), 0LL) << '\n';
}

signed main() {
  cin.tie(0)->sync_with_stdio(0);
  int t = 1;
  cin >> t;
  while (t --> 0) {
    solve();
  }
}