#include <bits/stdc++.h>
void solve() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> array(n * k + 1);
  long long sum = 0;
  int sub = n / 2;
  for (int i = 1; i <= n * k; i++) {
    std::cin >> array[i];
  }
  for (int i = 1, pos = n * k - sub; i <= k; i++, pos -= (sub + 1)) {
    sum += array[pos];
  }
  std::cout << sum << std::endl;
}
int main() {
  int T;
  std::cin >> T;
  while (T--) solve();
  return 0;
}
