#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int& x : a) cin >> x;
    sort(a.begin(), a.end());

    int l = (n - k - 1) / 2;              // floor((n - k - 1)/2)
    int r = (n + k) / 2;                  // floor((n + k)/2)

    cout << a[r] - a[l] + 1 << '\n';      // number of possible medians
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t; cin >> t;
    while (t--) solve();
}
