#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int q = 1; q <= t; q++) {
    int n;
    int k;
    cin >> n >> k;
    long long a[n * k + 10];
    long long ans = 0;
    for (int i = 1; i <= n * k; i++) cin >> a[i];
    int ind = n * k - n / 2;
    int cnt = n / 2 + 1;
    int col = 0;
    while (ind > col) {
      ans += a[ind];
      ind -= cnt;
      if (ind > 0) col += n - cnt;
    }
    cout << ans << "\n";
  }
  return 0;
}
