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