#include <bits/stdc++.h>
using namespace std;
int n, k;
int arr[1000009];
void solve() {
  int first = n / 2 + 1, it = n * k;
  long long ans = 0;
  for (int i = 0; i < k; i++) {
    ans += arr[it - first];
    it -= first;
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tt;
  cin >> tt;
  while (tt--) {
    cin >> n >> k;
    for (int i = 0; i < n * k; i++) cin >> arr[i];
    solve();
  }
  return 0;
}
