#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  cin >> n >> k;
  long long a[n * k];
  for (int i = 0; i < n * k; i++) {
    cin >> a[i];
  }
  long long sum = 0;
  int jump = ((n + 1) / 2);
  if (n % 2 == 0) jump++;
  int count = 0;
  for (int i = n * k - jump; count < k; i -= jump) {
    sum += a[i];
    count++;
  }
  cout << sum << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
