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