#include <bits/stdc++.h> using namespace std; typedef long long ll; ll t,n,k,v[100005]; void solve() { cin>>n>>k; for(int i=1;i<=n;i++) cin>>v[i]; ll big=0; ll mid=0; ll g=0; sort(v+1,v+n+1); ll j=n; for(int i=1;i<=n;i++) { while(j>i&&v[j]+v[i]>=k) j--; if(j>i) { g++; j--; } else break; } for(int i=1;i<=n;i++) if(v[i]>=k) big++; mid=n-big-2*g; ll ans=0; while(g>0&&mid+big>0) { ans++; if(big>0) big--; else mid--; g--; } if(g>0) ans+=(2*g)/3+((2*g)%3!=0); else { while(mid>0&&big>0) { mid--; big--; ans++; } if(mid>0) ans+=mid/2+mid%2; else ans+=big; } cout<<ans-1<<'\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin>>t; while(t--) solve(); return 0; }