#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000000ll;
int n, k;
int tab[200001];
void solve() {
  cin >> n >> k;
  long long ans = 0;
  for (int i = 1; i <= n * k; i++) cin >> tab[i];
  if (n % 2 == 0) {
    int dif = (n / 2) + 1;
    for (int idx = (n * k) + 1 - dif, kdx = 1; kdx <= k; idx -= dif, kdx++)
      ans += tab[idx];
    cout << ans << "\n";
  } else {
    int dif = (n / 2) + 1;
    for (int idx = (n * k) + 1 - dif, kdx = 1; kdx <= k; idx -= dif, kdx++)
      ans += tab[idx];
    cout << ans << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
