#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int MOD2 = MOD + 2;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return val < a ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(long double x, long double y) { return sign(x - y); }
int modulo(int a, int b) { return (a % b + b) % b; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long len = n * k;
    vector<long long> a(len + 10);
    for (int i = (1); i <= (len); i++) {
      cin >> a[i];
    }
    long long med = (n + 1) / 2;
    long long head = k * (med - 1) + 1, ans = 0;
    for (; head <= len; head += (n - med) + 1) {
      ans += a[head];
    }
    cout << ans << "\n";
  }
  return 0;
}

### Prompt

Create a solution in cpp for the following problem:

A median of an array of integers of length n is the number standing on the ⌈ {n/2} ⌉ (rounding up) position in the non-decreasing ordering of its elements. Positions are numbered starting with 1. For example, a median of the array [2, 6, 4, 1, 3, 5] is equal to 3. There exist some other definitions of the median, but in this problem, we will use the described one.

Given two integers n and k and non-decreasing array of nk integers. Divide all numbers into k arrays of size n, such that each number belongs to exactly one array.

You want the sum of medians of all k arrays to be the maximum possible. Find this maximum possible sum.

Input

The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The next 2t lines contain descriptions of test cases.

The first line of the description of each test case contains two integers n, k (1 ≤ n, k ≤ 1000).

The second line of the description of each test case contains nk integers a_1, a_2, …, a_{nk} (0 ≤ a_i ≤ 10^9) — given array. It is guaranteed that the array is non-decreasing: a_1 ≤ a_2 ≤ … ≤ a_{nk}.

It is guaranteed that the sum of nk for all test cases does not exceed 2 ⋅ 10^5.

Output

For each test case print a single integer — the maximum possible sum of medians of all k arrays.

Example

Input


6
2 4
0 24 34 58 62 64 69 78
2 2
27 61 81 91
4 3
2 4 16 18 21 27 36 53 82 91 92 95
3 4
3 11 12 22 33 35 38 67 69 71 94 99
2 1
11 41
3 3
1 1 1 1 1 1 1 1 1


Output


165
108
145
234
11
3

Note

The examples of possible divisions into arrays for all test cases of the first test:

Test case 1: [0, 24], [34, 58], [62, 64], [69, 78]. The medians are 0, 34, 62, 69. Their sum is 165.

Test case 2: [27, 61], [81, 91]. The medians are 27, 81. Their sum is 108.

Test case 3: [2, 91, 92, 95], [4, 36, 53, 82], [16, 18, 21, 27]. The medians are 91, 36, 18. Their sum is 145.

Test case 4: [3, 33, 35], [11, 94, 99], [12, 38, 67], [22, 69, 71]. The medians are 33, 94, 38, 69. Their sum is 234.

Test case 5: [11, 41]. The median is 11. The sum of the only median is 11.

Test case 6: [1, 1, 1], [1, 1, 1], [1, 1, 1]. The medians are 1, 1, 1. Their sum is 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int MOD2 = MOD + 2;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return val < a ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(long double x, long double y) { return sign(x - y); }
int modulo(int a, int b) { return (a % b + b) % b; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long len = n * k;
    vector<long long> a(len + 10);
    for (int i = (1); i <= (len); i++) {
      cin >> a[i];
    }
    long long med = (n + 1) / 2;
    long long head = k * (med - 1) + 1, ans = 0;
    for (; head <= len; head += (n - med) + 1) {
      ans += a[head];
    }
    cout << ans << "\n";
  }
  return 0;
}

```