#include <bits/stdc++.h>
using namespace std;
struct mycomp {
  bool operator()(pair<int, int> const& a, pair<int, int> const& b) {
    if (a.first == b.first) return a.second > b.second;
  }
};
int64_t ceil_div(int64_t a, int64_t b) { return (a + b - 1) / b; }
int64_t fact(signed long long int n) {
  return (n == 1 || n == 0) ? 1
                            : n % (int)(1e9 + 7) * fact(n - 1) % (int)(1e9 + 7);
}
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
vector<int> prime;
void printPrime(int n) {
  prime.push_back(1);
  for (int i = 2; i <= n; i++) {
    if (isPrime(i)) prime.push_back(i);
  }
}
void run_case() {
  int n, k;
  cin >> n >> k;
  vector<signed long long int> v;
  v.push_back(0);
  for (int i = 1; i <= n * k; i++) {
    int temp;
    cin >> temp;
    v.push_back(temp);
  }
  int med = (n + 1) / 2;
  signed long long int res = 0;
  int flag = 1, count = 0;
  for (int i = 1; i <= (n * k); i++) {
    if (i > ((med - 1) * k)) {
      if (flag == 1) res += v[i], count++;
      if (count == (n - med + 1))
        flag = 1, count = 0;
      else
        flag = 0, count++;
    }
  }
  cout << res << "\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    run_case();
  }
}
