#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) begin(x),end(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define sz(x) int(x.size())

int main() {
    cin.tie(NULL);
    cin.sync_with_stdio(false);
    int t; cin >> t;
    while(t--) {
    int n,k; cin >> n >> k;
    vi a(n);
    for(auto& i : a) cin >> i;
    sort(all(a));
    int l=0,r=n-1;
    int q = 0;
    for(auto i :  a) q+=i>=k;
    int p=0;
    while(l<r) {
        if(a[l]+a[r]>=k) {
            --r;
        } else {
            l++;
            r--;
            p++;
        }
    }
    int ans=n;
    auto upans = [&]() {
        int left = n-p*2-q;
        left-=abs(q-p);
        left=max(left,0);
        ans = min(ans, max(p,q) + (left+1)/2 );
    };
    upans();
    while(p>0) {
        p--;
        upans();
    }

    cout << ans-1<< '\n';
    }
    

}