#include <bits/stdc++.h>
using namespace std;
bool prime[1000000 + 1];
void SieveOfEratosthenes() {
  memset(prime, true, sizeof(prime));
  prime[1] = false;
  for (int p = 2; p * p <= 1000000; p++) {
    if (prime[p] == true) {
      for (int i = p * 2; i <= 1000000; i += p) prime[i] = false;
    }
  }
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int modexp(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int mypow(long long int b, long long int e) {
  long long int ans = 1;
  for (; e; b = b * b % 1000000007, e /= 2)
    if (e & 1) ans = ans * b % 1000000007;
  return ans;
}
long long int power2(long long int x, long long int y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power2(x, y / 2) * power2(x, y / 2);
  else
    return x * power2(x, y / 2) * power2(x, y / 2);
}
long long int conv(char c) { return (long long int)(c - 'a'); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int a[n * k];
    for (long long int i = 0, _n = (n * k); i < _n; i++) cin >> a[i];
    long long int ans = 0;
    long long int med = (n % 2 == 0) ? (n / 2) : (n / 2 + 1);
    long long int rem = n - med + 1;
    med--;
    long long int count = 1;
    long long int i = 0;
    long long int j = (n * k - 1);
    if (j == 0) {
      cout << a[0] << endl;
      continue;
    }
    while (i < j) {
      while (count < rem) {
        j--;
        count++;
      }
      ans += a[j];
      count = 1;
      while (count <= med) {
        i++;
        count++;
      }
      count = 0;
    }
    cout << ans << endl;
  }
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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;
bool prime[1000000 + 1];
void SieveOfEratosthenes() {
  memset(prime, true, sizeof(prime));
  prime[1] = false;
  for (int p = 2; p * p <= 1000000; p++) {
    if (prime[p] == true) {
      for (int i = p * 2; i <= 1000000; i += p) prime[i] = false;
    }
  }
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int modexp(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int mypow(long long int b, long long int e) {
  long long int ans = 1;
  for (; e; b = b * b % 1000000007, e /= 2)
    if (e & 1) ans = ans * b % 1000000007;
  return ans;
}
long long int power2(long long int x, long long int y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power2(x, y / 2) * power2(x, y / 2);
  else
    return x * power2(x, y / 2) * power2(x, y / 2);
}
long long int conv(char c) { return (long long int)(c - 'a'); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int a[n * k];
    for (long long int i = 0, _n = (n * k); i < _n; i++) cin >> a[i];
    long long int ans = 0;
    long long int med = (n % 2 == 0) ? (n / 2) : (n / 2 + 1);
    long long int rem = n - med + 1;
    med--;
    long long int count = 1;
    long long int i = 0;
    long long int j = (n * k - 1);
    if (j == 0) {
      cout << a[0] << endl;
      continue;
    }
    while (i < j) {
      while (count < rem) {
        j--;
        count++;
      }
      ans += a[j];
      count = 1;
      while (count <= med) {
        i++;
        count++;
      }
      count = 0;
    }
    cout << ans << endl;
  }
}

```