#include <bits/stdc++.h>
using namespace std;
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(nullptr);
  int T = 1;
  cin >> T;
  int cases = 0;
  while (T--) {
    cases++;
    int n, k;
    cin >> n >> k;
    int N = n * k;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
      cin >> a[i];
    }
    int c = n + 1;
    long long int result = 0;
    for (int i = N - 1; i >= 0; i--) {
      c--;
      if (c == (n + 1) / 2) {
        c = n + 1;
        result += a[i];
        k--;
        if (k == 0) {
          break;
        }
      }
    }
    cout << result << endl;
  }
}
