#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const long long N = 2e6 + 10;
const long long IM = 1e15 + 37;
const long double PI = 3.1415926535897932384;
inline void PP(long long n) { cout << n << " "; }
void IN(vector<long long>& arr, long long n, long long x = 0) {
  for (long long i = x; i < n + x; i++) cin >> arr[i];
}
void PV(vector<long long> v) {
  for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << "\n";
}
void PVR(vector<long long> v) {
  for (long long i = v.size() - 1; i >= 0; i--) cout << v[i] << " ";
  cout << "\n";
}
void PVV(vector<pair<long long, long long> > v) {
  for (long long i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << "\n";
}
void PA(long long v[], long long n, long long x = 0) {
  for (long long i = x; i < n + x; i++) cout << v[i] << " ";
  cout << "\n";
}
void IN(long long a[], long long n, long long x = 0) {
  for (long long i = x; i < n + x; i++) cin >> a[i];
}
void fun() {
  long long n, k;
  cin >> n >> k;
  long long a[n * k];
  long long m = n * k;
  for (long long i = 0; i < m; i++) cin >> a[i];
  long long i = k;
  long long ans = 0;
  for (long long j = m - n / 2 - 1; j >= 0 && i > 0; j -= (n / 2 + 1), i--) {
    ans += a[j];
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  t = 1;
  cin >> t;
  while (t--) {
    fun();
  }
  return 0;
}
