#include <bits/stdc++.h>
using namespace std;
const int mxN = 1000000;
int a[mxN];
void solve() {
  int n, k;
  cin >> n >> k;
  int idx = ceil((double)n / 2);
  int sub = (n - idx) + 1;
  for (int i = 0; i < n * k; i++) {
    cin >> a[i];
  }
  long long ans = 0, cnt = 0;
  for (int i = n * k - sub; cnt < k; i -= sub) {
    ans += a[i];
    cnt++;
  }
  cout << ans << "\n";
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
