#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define For(i,a , n)for(ll i = a;i<(ll)n;i++)
#define vec vector
#define all(x) begin(x), end(x)
#define sz(x)(ll)size(x)

template<class A, class B>
pair<A, B> operator+(const pair<A, B>& a, const pair<A, B>& b){
    return {a.first + b.first, a.second + b.second};
}

template<class A, class B>
ostream& operator<<(ostream& os, const pair<A, B>& a){
    return os<<"("<<a.first<<", "<<a.second<<")";
}

template<class A, class B, class C>
basic_ostream<A, B>& operator<<(basic_ostream<A, B>& os, const C& c){
    for(auto itr = begin(c);itr!=end(c);++itr){
        os<<(itr==begin(c)?"":" ")<<*itr;
    }
    return os;
}

template<typename... Args>
void dbg(Args&&... args){
    ((cerr<<args<<"| "),...);
    cerr<<endl;
}

void solve(){
    ll n, k;
    cin >> n >> k;

    vec<ll> v(n);
    For(i, 0, n) cin >> v[i];
    sort(all(v));



    ll l = 0, h = n;
    while(h-l-1 > 0)
    {
        ll m = (l+h)/2;
        if(m%2 == 0) m--;
        // dbg(l, h);
        For(i, 0, (m+1)/2)
        {
            // dbg(i, m-i, m);
            if(v[i] + v[m-i] >= k)
            {
                h = m;
                continue;
            }
            l = m;
        }
        h = m;
    }

    // dbg(v);
    // dbg(l);
    ll res = n-1;
    For(i, 0, n)
    {
        if(v[i] >= k) break;
        

        ll x = (min(i, l)+1)/2;

        if(i-x <= n-i)
        {
            // dbg(i, x);
            res = min(res, n-i-1);
        }


    }

    cout << res << '\n';


}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
    ll t = 1; cin>>t;
    while(t--)solve();
}