#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<ll> a(m);
  for (auto& it : a) cin >> it;
  gp_hash_table<pair<ll, ll>, bool> dp, ndp;
  dp.insert({{0, 0}, 0});
  for (int i = 0; i < m; ++i) {
    for (auto [p, _] : dp) {
      auto [j, k] = p;
      ndp.insert({{a[i] - j, k}, 0});
      ndp.insert({{j, a[i] - k}, 0});
    }
    dp = ndp;
    ndp.clear();
  }
  ll ans = -1e17;
  for (auto [p, _] : dp) {
    auto [i, j] = p;
    ans = max(ans, i + j);
  }
  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();
  }
}