#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll inf = LONG_LONG_MAX;
ll binpow(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % 1000000007;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return (res % 1000000007);
}
signed main() {
  ll t;
  cin >> t;
  while (t--) {
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n * k);
    for (ll i = 0; i < (n * k); i++) {
      cin >> v[i];
    }
    ll a = (-1);
    if (n % 2 == 1) {
      a = (n / 2) + 1;
    } else {
      a = (n / 2);
    }
    a = (n - a + 1);
    ll ans = 0;
    for (ll i = (n * k - a); k > 0; i = i - a, k--) {
      ans = ans + v[i];
    }
    cout << ans << "\n";
  }
  return 0;
}
