#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;

int max_el(const vector<ll>& a) {
  return max(abs(*min_element(a.begin(), a.end())), *max_element(a.begin(), a.end()));
}

struct comp {
  bool operator()(const vector<ll>& a, const vector<ll>& b) const {
    int ma = max_el(a);
    int mb = max_el(b);
    return ma < mb || (ma == mb && a < b);
  }
};

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (auto& it : a) cin >> it;
  set<vector<ll>, comp> s, s2;
  s.insert(vector<ll>(n));
  for (int i = 0; i < m; ++i) {
    for (auto vec : s) {
      for (int j = 0; j < n; ++j) {
        int t = vec[j];
        vec[j] = a[i] - vec[j];
        s2.insert(vec);
        vec[j] = t;
      }
    }
    auto ff = *s2.begin();
    auto ss = *s2.rbegin();
    s.clear();
    s.insert(ff);
    s.insert(ss);
    s2.clear();
  }
  ll ans = -1e17;
  for (auto& vec : s) {
    ans = max(ans, accumulate(vec.begin(), vec.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();
  }
}