#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> a(n * k + 1);
    for (int i = 1; i <= n * k; i++) {
      scanf("%d", &a[i]);
    }
    int x = n - int(ceil(double(n) / 2));
    long long ans = 0;
    for (int i = n * k - x, j = 1; j <= k; i -= (x + 1), j++) {
      ans += a[i];
    }
    printf("%lld\n", ans);
  }
}
