#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, k, left, middle, right, temp, count;
  long long int sum;
  cin >> t;
  while (t--) {
    sum = 0;
    count = 0;
    cin >> n >> k;
    middle = n / 2 + n % 2;
    left = middle - 1;
    right = n - middle;
    for (int i = 1; i <= n * k; i++) {
      cin >> temp;
      if (i == left * k + 1 + (right + 1) * count) {
        sum += temp;
        count++;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
