#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1e18;
const int N = 1e5 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    vector<int> a((n * k) + 5);
    for (int i = 1; i <= n * k; i++) {
      cin >> a[i];
    }
    long long ans = 0;
    int l = 1, r = n * k;
    if (n % 2 == 1) {
      while (l <= r) {
        int bad = n / 2;
        while (bad--) r--, l++;
        ans += a[r];
        r--;
      }
      cout << ans << "\n";
    } else {
      while (l <= r) {
        int bad = n / 2;
        while (bad--) r--, l++;
        l--;
        ans += a[r];
        r--;
      }
      cout << ans << "\n";
    }
  }
  return 0;
}
