#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(n);
  for (auto& it : a) cin >> it;
  ll ans = -1e18;
  for (int i = 0; i < (1 << m); ++i) {
    vector<ll> b(2);
    for (int j = 0; j < m; ++j) {
      if (i >> j & 1) {
        b[0] = a[j] - b[0];
      } else {
        b[1] = a[j] - b[1];
      }
    }
    ans = max(ans, b[0] + b[1]);
  }
  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();
  }
}