#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma warning(disable : 4996)
const int maxn = 100 + 6;
const int maxa = 1000 * 1000 * 1000 + 7;
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int t, n, m, T;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> T;
  for (int kase = 1; kase <= T; kase++) {
    int n, k;
    long long sum = 0;
    cin >> n >> k;
    int epoch = n / 2;
    vector<int> a(n * k);
    for (int i = 0; i < n * k; i++) {
      cin >> a[i];
    }
    int j = 0;
    for (int i = n * k - epoch - 1; i >= 0; i -= epoch + 1) {
      if (j >= k) break;
      sum += a[i];
      j++;
    }
    cout << sum << "\n";
  }
  return 0;
}
