#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n * k);
  for (auto &it : a) cin >> it;
  reverse(a.begin(), a.end());
  long long ans = 0;
  int mid = n / 2, cnt = 0;
  for (int i = mid; i < (int)a.size() && cnt++ != k; i += mid + 1) {
    ans += a[i];
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
