#include <bits/stdc++.h>
using namespace std;
template <typename t>
t ceil(t a, t b) {
  return a / b + (a % b == 0 ? 0 : 1);
}
bool comp(pair<int, int> p1, pair<int, int> p2) {
  if (p2.second > p1.second) {
    return 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t{1};
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    vector<int> arr(n * k + 1);
    arr[0] = 0;
    for (auto i{0}; i < n * k; i++) {
      cin >> arr[i + 1];
    }
    int median = n / 2 + (n & 1 ? 1 : 0);
    int r = n * k;
    long long int ans = 0;
    int count = 0;
    int diffR = n - median;
    while (count < k) {
      ans += (long long int)arr[r - diffR];
      r = r - diffR - 1;
      count++;
    }
    cout << ans << "\n";
  }
  return 0;
}
