#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i = (a); i < (b); ++i)
#define REP(i,n) rep(i,0,n)
#define sz(v) ((int) (v).size())
#define rs resize
#define all(v) begin(v), end(v)

void run(){
    ll n, k;
    cin >> n>> k;
    vi d = vi(n);
    for(ll i = 0; i < n; i++)
        cin >> d[i];
    sort(all(d));

    //Bepaal de matches
    ll l = 0, r = 2 * ((n + 2) / 3) + 1, m;
    while(r - l > 1){
        m = (l + r) / 2;
        bool kan = true;
        for(ll i = 0; i < m; i++)
            if(d[i] + d[m-1-i] >= k) {
                kan = false;
                break;
            }
        if(kan)
            l = m;
        else
            r = m;
    }
    m = l;
    m /= 2;
    if(3 * m >= n){
        cout << (m - 1) << endl;
        return;
    }

    //Bepaal het antwoord
    ll antw = m;
    ll klein = 0;
    for(ll i = 2 * m; i < n - m; i++)
        if(d[i] < k)
            klein++;
    if(klein * 2 < n - 3 * m) //Nu doen we alle kleine paren
    {
        antw += klein + (n - 3 * m - 2 * klein);
    }
    else{
        antw += (n - 3 * m + 1) / 2;
    }
    antw--;
    cout << antw << endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(20);
    ll t;
    for(cin >> t; t > 0; t--)
        run();
    return 0;
}