#include <bits/stdc++.h>
using namespace std;
long long a[1000005];
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    for (long long i = 1; i <= n * k; i++) {
      cin >> a[i];
    }
    long long len = n / 2 + 1;
    long long ans = 0;
    long long curr = n * k - len + 1;
    while (k--) {
      ans += a[curr];
      curr -= len;
    }
    cout << ans << endl;
  }
}
