#include <bits/stdc++.h>
long long int power(long long int x, long long int n) {
  long long int result = 1;
  while (n) {
    if (n % 2 == 1) result = result * x;
    n = n / 2;
    x = x * x;
  }
  return result;
}
long long int gcd(long long int a, long long int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int BS(long long int a[], long long int s, long long int n,
                 long long int val) {
  long long int mid, beg = s, end = n - 1;
  while (beg <= end) {
    mid = (beg + end) / 2;
    if (val == a[mid]) {
      break;
    } else if (val > a[mid]) {
      beg = mid + 1;
    } else {
      end = mid - 1;
    }
  }
  return mid;
}
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int d, ans = 0;
    d = (n / 2) + 1;
    long long int a[n * k];
    for (long long int i = 0; i < n * k; i++) cin >> a[i];
    long long int count = k;
    if (n != 2 && n != 1) {
      for (long long int j = n * k - d; j >= 0; j -= d) {
        ans += a[j];
        count--;
        if (count == 0) break;
      }
      cout << ans << "\n";
    } else if (n == 2) {
      long long int x = k;
      for (long long int i = 0; i < n * k; i++) {
        ans += a[i];
        x--;
        i++;
        if (x == 0) break;
      }
      cout << ans << "\n";
    } else if (n == 1) {
      for (long long int i = 0; i < n * k; i++) ans += a[i];
      cout << ans << "\n";
    }
  }
  return 0;
}
