#include <bits/stdc++.h>
using namespace std;
vector<bool> visited(300000, false);
vector<vector<int>> v;
vector<int> distanc(300000, 0);
queue<int> q;
struct sort_pred {
  bool operator()(const std::pair<int, long long> &left,
                  const std::pair<int, long long> &right) {
    return left.second < right.second;
  }
};
char asciitolower(char in) {
  if (in <= 'Z' && in >= 'A') return in - ('Z' - 'z');
  return in;
}
vector<int> vdeep_copy(vector<int> a) {
  vector<int> b(a.size());
  for (int i = 0; i < a.size(); i++) {
    b[i] = a[i];
  }
  return b;
}
int arr_max(vector<int> a) {
  int ans = -1000000000;
  for (int i = 0; i < a.size(); i++) ans = max(a[i], ans);
  return ans;
}
void to_lower(string &st) {
  std::transform(st.begin(), st.end(), st.begin(), asciitolower);
}
void dfs(int node) {
  if (visited[node]) return;
  visited[node] = true;
  for (auto u : v[node]) dfs(u);
}
void bfs(int x) {
  visited[x] = true;
  distanc[x] = 0;
  q.push(x);
  while (!q.empty()) {
    int s = q.front();
    q.pop();
    for (auto u : v[s]) {
      if (visited[u]) continue;
      visited[u] = true;
      distanc[u] = distanc[s] + 1;
      q.push(u);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  vector<long long> reqs(t);
  for (int q = 0; q < t; q++) {
    int n, m;
    cin >> n >> m;
    int k = n / 2 + 1;
    int g = n % 2 ? n / 2 : (n + 1) / 2;
    vector<long long> a(n * m);
    for (int i = 0; i < n * m; i++) cin >> a[i];
    long long sm = 0;
    for (int i = 0; i < m; i++) {
      sm += a[n * m - 1 - g - k * i];
    }
    reqs[q] = sm;
  }
  for (int i = 0; i < t; i++) cout << reqs[i] << endl;
}
