#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};
void solve(int test_case) {
  int n, k;
  cin >> n >> k;
  int s = n * k;
  vector<long long int> v(s);
  for (int i = 0; i < s; i++) {
    cin >> v[i];
  }
  int i = s - 1 - (n / 2);
  long long int ans = 0;
  while (k--) {
    ans += v[i];
    i -= (n / 2) + 1;
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve(i);
  }
  return 0;
}
