#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 1ll << 60;
const int mod = 1e9 + 7;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
void solve() {
  int n, k, a[200010];
  cin >> n >> k;
  for (int i = 1; i <= n * k; i++) cin >> a[i];
  int pos = n / 2;
  int kkk = n - pos;
  long long ans = 0, cnt = 0;
  for (int i = n * k, j = 1; i >= 0; i--) {
    if (j > pos) {
      ans += a[i];
      j = 0;
      cnt++;
      if (cnt == k) break;
    }
    j++;
  }
  cout << ans << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
