#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
inline long long max3(long long a, long long b, long long c) {
  return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c));
}
inline long long min3(long long a, long long b, long long c) {
  return (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c));
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int a[(n * k) + 1];
    for (long long int i = 1; i <= (n * k); i++) cin >> a[i];
    long long int m = n / 2, res = 0, c = 0;
    long long int i = (n * k) - m;
    c = 1;
    while (c <= k) {
      res += a[i];
      i = i - m - 1;
      c++;
    }
    cout << res << endl;
  }
  return 0;
}
