#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const int maxm = 1e3 + 5;
const int ioo = 1e9 + 5;
const long long loo = 1e18 + 5;
const int mod = 1e9 + 7;
long long a[maxn], res;
int cc, n, k, t, dem, nhay;
deque<long long> dq;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> k;
    for (int i = 1; i <= n * k; i++) {
      cin >> a[i];
      dq.push_back(a[i]);
    }
    res = 0;
    cc = k * n - nhay;
    while (dq.size()) {
      nhay = n / 2;
      while (nhay && dq.size()) {
        nhay--;
        dq.pop_back();
      }
      dem = n - n / 2;
      if (dq.size()) {
        res += dq.back();
        dq.pop_back();
        dem--;
      }
      while (dem && dq.size()) {
        dq.pop_front();
        dem--;
      }
    }
    cout << res << '\n';
  }
}
