#include <bits/stdc++.h>
using namespace std;
constexpr int64_t N = 2e5;
int32_t main() {
  int64_t t;
  cin >> t;
  while (t--) {
    int64_t n, k;
    cin >> n >> k;
    deque<int64_t> a(n * k);
    for (auto &i : a) cin >> i;
    int64_t ans = 0;
    int64_t r = n * k - n / 2 - 1, cnt = 0;
    while (cnt < k) {
      ans += a[r];
      cnt++;
      r = r - n / 2 - 1;
    }
    cout << ans << '\n';
  }
}
