#include <bits/stdc++.h>
int col8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int row8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int col4[4] = {1, 0, -1, 0};
int row4[4] = {0, 1, 0, -1};
using namespace std;
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
T power(T n, T p) {
  T res = 1;
  for (int i = 0; i < p; i++) res *= n;
  return res;
}
template <class T>
double getdist(T a, T b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
template <class T>
T extract(string s, T ret) {
  stringstream ss(s);
  ss >> ret;
  return ret;
}
template <class T>
string tostring(T n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
struct fast {
  fast() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  }
} cincout;
long long arr[2000010];
int main() {
  int test, n, k;
  cin >> test;
  while (test--) {
    cin >> n >> k;
    for (int i = 1; i <= n * k; i++) cin >> arr[i];
    long long res = 0;
    for (int i = n * k - n + (n + 1) / 2, j = 0; j < k;
         i -= n - (n - 1) / 2, j++) {
      res += arr[i];
    }
    cout << res << "\n";
  }
  return 0;
}
