#include <bits/stdc++.h>
using namespace std;
int main() {
  int tests;
  cin >> tests;
  for (int tes = 0; tes < tests; ++tes) {
    int n, k;
    cin >> n >> k;
    vector<int> a(n * k);
    for (int i = 0; i < n * k; ++i) {
      cin >> a[i];
    }
    long long ans = 0;
    int last = n - ((n + 1) / 2 - 1);
    int pos = n * k;
    int cnt = k;
    while (cnt) {
      ans += a[pos - last];
      cnt--;
      pos -= last;
    }
    cout << ans << endl;
  }
}
