#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, k;
    cin >> n >> k;
    vector<long long> a;
    for (int j = 0; j < n * k; j++) {
      long long ele;
      cin >> ele;
      a.push_back(ele);
    }
    int x = ceil((float(n)) / 2);
    long long sum = 0;
    for (int j = k * (x - 1); j < k * n; j = j + (n - x + 1)) {
      sum = sum + a.at(j);
    }
    cout << sum << endl;
  }
}
