#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void prn(bool space, Arg1&& arg1) {
  cout << arg1;
  if (space)
    cout << " ";
  else
    cout << "\n";
}
template <typename Arg1, typename... Args>
void prn(bool space, Arg1&& arg1, Args&&... args) {
  prn(space, arg1);
  prn(space, args...);
}
const long long mod = 1000000007;
const long long MOD = 998244353;
const long long inf = 1e18;
const long long MAX = 2e5 + 1;
inline long long add(long long a, long long b) {
  return ((a % mod) + (b % mod)) % mod;
}
inline long long sub(long long a, long long b) {
  return ((a % mod) - (b % mod) + mod) % mod;
}
inline long long mul(long long a, long long b) {
  return ((a % mod) * (b % mod)) % mod;
}
vector<long long> fac(1e6);
long long pwr(long long x, long long n) {
  x = x % mod;
  if (!n) return 1;
  if (n & 1)
    return mul(x, pwr(mul(x, x), (n - 1) / 2));
  else
    return pwr(mul(x, x), n / 2);
}
long long modinv(long long n) { return pwr(n, mod - 2); }
long long inv(long long i) {
  if (i == 1) return 1;
  return (MOD - (MOD / i) * inv(MOD % i) % MOD) % MOD;
}
long long ncr(long long n, long long r) {
  long long ans = 1;
  if (r != 0 && r != n) {
    ans = fac[n] * modinv(fac[r]) % MOD * modinv(fac[n - r]) % MOD;
  }
  return ans;
}
void pre() {
  fac[0] = 1;
  for (int i = 1; i < (int)fac.size(); i++) {
    fac[i] = (fac[i - 1] * i) % MOD;
  }
}
void solve() {
  long long n, k;
  cin >> n >> k;
  long long a[n * k + 1];
  for (int i = 1; i <= n * k; i++) {
    cin >> a[i];
  }
  long long median = (n + 1) / 2;
  long long skip = (median - 1) * k;
  long long skip2 = n - (median - 1);
  long long ans = 0;
  for (int i = skip + 1; i <= n * k; i += skip2) {
    ans += a[i];
  }
  cout << ans << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
