#include <bits/stdc++.h>
using namespace std;
void normtest() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long k;
    cin >> k;
    long long s = n * k;
    unsigned long long sum1 = 0;
    long long val = (n + 1) / 2;
    long long ar[s];
    for (long long i = 0; i < s; i++) {
      cin >> ar[i];
    }
    unsigned long long sum2 = 0;
    for (long long i = 0, j = s - 1; k--;) {
      long long count = 1;
      while (count < val) i++, count++;
      long long c2 = n;
      while (c2 > val) c2--, j--;
      sum2 += ar[j];
      j--;
    }
    cout << sum2;
    cout << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  normtest();
  return 0;
}
