#include <bits/stdc++.h>
const int INF = 1e9;
const int N = 2e5 + 5;
using namespace std;
int Exp(int x, int y) {
  int ans = 1;
  for (int i = 1; i <= y; i++) ans *= x;
  return ans;
}
vector<bool> check_prime(N + 1, true);
void Seive() {
  check_prime[0] = false;
  check_prime[1] = false;
  for (long long i = 2; i * i <= N; i++) {
    if (check_prime[i]) {
      for (long long j = i * i; j <= N; j += i) check_prime[j] = false;
    }
  }
}
bool prime(int x) {
  bool ok = true;
  if (x < 2) return false;
  if (x == 2)
    return true;
  else {
    for (int i = 2; i * i <= x; i++) {
      if (x % i == 0) {
        return false;
      }
    }
    return true;
  }
}
int dp[1000000];
int h[1000000];
void solve(int tc) {
  long long n, k;
  cin >> n >> k;
  long long a[n * k];
  for (long long i = 0; i <= n * k - 1; i++) {
    cin >> a[i];
  }
  long long t;
  if (n % 2 == 0) {
    t = (n / 2) - 1;
  } else
    t = n / 2;
  long long ans = 0;
  long long c = 0;
  if (t == 0) {
    for (long long i = n * k - n; i >= 0 && c < k; i -= n) {
      ans += a[i];
      c++;
    }
    cout << ans << "\n";
  } else {
    for (long long i = n * k - n + t; i >= 0 && c < k; i -= (n - t)) {
      ans += a[i];
      c++;
    }
    cout << ans << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve(i);
  }
}
