#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, k, tmp;
  vector<long long> ans;
  vector<int> vec;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    for (int i = 0; i < n * k; i++) {
      cin >> tmp;
      vec.push_back(tmp);
    }
    int med;
    if (n % 2 == 0)
      med = n / 2;
    else
      med = n / 2 + 1;
    long long medSum = 0;
    int pos = vec.size() - (n - med) - 1;
    for (int i = 0; i < k; i++) {
      medSum += (long long)vec[pos];
      pos -= (n - med + 1);
    }
    ans.push_back(medSum);
    vec.clear();
  }
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
}
