#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int arr[n * k];
    for (int i = 0; i < n * k; i++) {
      cin >> arr[i];
    }
    int x = (n / 2) + 1;
    if (n == 1 && k == 1) {
      cout << arr[0] << endl;
    } else {
      int cnt = 0;
      unsigned long long int ans = 0;
      for (int i = n * k - x; i >= 0; i -= x) {
        ans += arr[i];
        cnt++;
        if (cnt == k) {
          break;
        }
      }
      cout << ans << endl;
    }
  }
}
