#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;
  vector<int> a(m); 
  for (auto& it : a) cin >> it;
  ll ans = -1e17;
  for (int mask = 0; mask < (1 << m); ++mask) {
    multiset<ll> b;
    for (int i = 0; i < n; ++i) b.insert(0);
    for (int i = 0; i < m; ++i) {
      if (mask >> i & 1) {
        ll x = *b.begin();
        b.extract(x);
        b.insert(a[i] - x);
      } else {
        ll x = *b.rbegin();
        b.extract(x);
        b.insert(a[i] - x);
      }
    }
    ans = max(ans, accumulate(b.begin(), b.end(), 0LL));
  }
  cout << ans << '\n';
}

signed main() {
  // freopen("in", "r", stdin);
  cin.tie(0)->sync_with_stdio(0);
  int t = 1;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    solve();
  }
}