#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(NULL);
  int m;
  cin >> m;
  while (m--) {
    long long int a, b;
    cin >> a >> b;
    long long int c[1 + a * b], k = a * b, j = 1 + b, ans = 0;
    for (long long int i = 1; i < 1 + a * b; i++) cin >> c[i];
    int x = (a + 1) / 2 - 1, y = x;
    x *= b;
    int i = x + 1;
    while (1) {
      if (i > a * b) break;
      ans += c[i];
      i += (a - y);
    }
    cout << ans << '\n';
  }
  return 0;
}
