#include <bits/stdc++.h>
const int MAX = 1e6 + 10;
const int MOD = 1e9 + 7;
using namespace std;
long long a[MAX];
int main() {
  ios::sync_with_stdio(false), cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    long long cnt = 0;
    cin >> n >> k;
    for (int i = 1; i <= n * k; i++) cin >> a[i];
    int g = 1;
    for (int i = n * k - n / 2; g <= k; i -= n / 2 + 1, g++) {
      cnt += a[i];
    }
    cout << cnt << endl;
  }
}
