#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  cin >> n >> k;
  int m = n * k;
  vector<int> a(m);
  for (int i = 0; i < m; i++) cin >> a[i];
  long long total = 0;
  if (n == 2) {
    for (int i = 0; i < m; i += 2) total += (long long)(a[i]);
    cout << total << "\n";
    return;
  }
  int interval = (n + 1) / 2;
  int left = n - interval;
  left++;
  int x = 1;
  int in = 0;
  for (int i = m - 1; i >= 0; i--) {
    if (x % left == 0) {
      total += a[i];
      in++;
    }
    x++;
    if (in >= k) break;
  }
  cout << total << "\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
