#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  for (int u = 0; u < t; u++) {
    long long int n, k;
    cin >> n >> k;
    vector<long long int> A;
    for (long long int i = 0; i < n * k; i++) {
      long long int x;
      cin >> x;
      A.push_back(x);
    };
    long long int median_ind = ((n + 1) / 2) - 1;
    long long int number_greater_than_each = n - (median_ind + 1);
    long long int first_ind = n * k - number_greater_than_each - 1;
    long long int ans = 0;
    for (int i = 0; i < k; i++) {
      ans += A[first_ind];
      first_ind -= (number_greater_than_each + 1);
    }
    cout << ans << endl;
  }
  return 0;
}
