#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int t;
  cin >> t;
  for (long long int f = 0; f < t; f++) {
    long long int n, k;
    cin >> n >> k;
    long long int A[n * k], i;
    for (i = 0; i < n * k; i++) cin >> A[i];
    long long int v;
    if (n % 2 == 0)
      v = n / 2;
    else
      v = n / 2 + 1;
    long long int sum = 0;
    long long int count = 0;
    long long int r = n - v;
    i = n * k - 1;
    i = i - r;
    while (i >= 0) {
      sum = sum + A[i];
      count++;
      if (count == k) break;
      i = i - r - 1;
    }
    cout << sum << endl;
  }
}
