#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int arr[n * k];
    for (long long int &i : arr) cin >> i;
    long long int t;
    if (n % 2 == 0)
      t = n / 2;
    else
      t = n / 2 + 1;
    t = n - t + 1;
    long long int ans = 0;
    long long int i = 0, tt = n * k;
    while (i != k) {
      ans += (arr[tt - t]);
      i++;
      tt -= t;
    }
    cout << ans << "\n";
  }
  return 0;
}
