#include <bits/stdc++.h>
using namespace std;
int64_t mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int casi;
  cin >> casi;
  while (casi--) {
    int n, k;
    cin >> n >> k;
    int arr[n * k];
    for (int i = 0; i < n * k; i++) cin >> arr[i];
    int64_t sol = 0;
    int tmp = n * k - (n + 2) / 2;
    for (int i = 0; i < k; i++) sol += arr[tmp - ((n + 2) / 2) * i];
    cout << sol << '\n';
  }
}
