#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int INF = 1e9 + 7;
const long long mod = 1e9 + 7;
int T, n, k;
int a[maxn];
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &k);
    int temp = n * k;
    for (int i = 1; i <= temp; i++) {
      scanf("%d", &a[i]);
    }
    long long sum = 0;
    if (n == 1) {
      for (int i = 1; i <= temp; i++) {
        sum = sum + 1LL * a[i];
      }
      printf("%lld\n", sum);
    } else if (n == 2) {
      for (int i = 1; i <= temp; i += 2) {
        sum = sum + 1LL * a[i];
      }
      printf("%lld\n", sum);
    } else {
      int mid = (n + 1) / 2;
      int dis = n - mid + 1;
      int cnt = 0;
      for (int i = temp - dis + 1; cnt < k; i = i - dis) {
        sum = sum + 1LL * a[i];
        cnt++;
      }
      printf("%lld\n", sum);
    }
  }
  return 0;
}
