#include <bits/stdc++.h>
using namespace std;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const long long int MAX = 2e18;
int main() {
  int t;
  cin >> t;
  while (t--) {
    unsigned long long int n, k, a, sm = 0, cnt = 0;
    cin >> n >> k;
    vector<unsigned long long int> v;
    for (int i = 0; i < n * k; i++) {
      cin >> a;
      v.push_back(a);
    }
    a = 0;
    for (int i = n * k - 1; i >= 0; i--) {
      cnt++;
      if (cnt == (n / 2) + 1) {
        cnt = 0;
        sm += v[i];
        a++;
        if (a == k) {
          break;
        }
      }
    }
    cout << sm << endl;
  }
  return 0;
}
