// tch1cherin GM!
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
#pragma GCC target("avx2,tune=native")
using namespace std;

constexpr long long INF = 1e18;

bool vsuprun() {
  static int it = 0;
  static bool done = false;
  if (done) {
    return true;
  }
  if (++it == 1000) {
    done = 1.0 * clock() / CLOCKS_PER_SEC >= 1.5;
    it = 0;
  }
  return done;
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int &value : x) {
      cin >> value;
    }
    reverse(x.begin(), x.end());
    vector<long long> dp(n + m + 1, -INF);
    dp[0] = 0;
    for (int i = 0; i < m; i++) {
      if (!vsuprun()) {
        for (int j = i + n - 1; j >= i; j--) {
          dp[j + 2] = max(dp[j + 2], dp[j] + x[i]);
        }
      } else {
        for (int j = i + n - 1; j >= i && j >= i + n - 1 - 1000; j--) {
          dp[j + 2] = max(dp[j + 2], dp[j] + x[i]);
        }
      }
    }
    long long total = accumulate(x.begin(), x.end(), 0LL);
    long long max_dp = *max_element(dp.begin() + m, dp.end());
    cout << 2 * max_dp - total<< "\n";
  }
}
