#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
inline int read() {
  int ret = 0, sgn = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') sgn = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    ret = ret * 10 + ch - '0';
    ch = getchar();
  }
  return ret * sgn;
}
struct MN {
  int a;
  int b;
};
const int maxn = 1e6 + 10;
int in[maxn];
bool cmp(int a, int b) { return a > b; }
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int lim = n * k;
    for (int i = 1; i <= lim; ++i) {
      cin >> in[i];
    }
    long long ans = 0;
    int md = n - (n + 1) / 2 + 1;
    for (int i = lim, now = 0, cnt = 1; i >= 1 && now < k; --i, cnt++) {
      if (cnt % md == 0) {
        ans += in[i];
        now++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
