#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int t; cin>>t; while(t--){ int n,k;cin>>n>>k; vector<int> v(n); for(int i = 0 ; i < n ; i ++){ cin>>v[i]; } sort(v.begin(),v.end()); // vector<bool> used(n); vector<int> rem; int tc = 0; for(int i = 0,j=n-1 ; j>=i ; i ++){ while(j>i && v[j] + v[i] >= k){ rem.push_back(v[j]); j--; } if(j>i){ j--; tc++; }else{ rem.push_back(v[j]); j--; } } std::reverse(rem.begin(), rem.end()); if(rem.size() >= tc){ rem.resize(rem.size()-tc); if(rem.size() == 0){ cout << tc-1 <<endl; continue; } int clk = 0; for(int i = 0 ; i < rem.size() ; i ++){ if(rem[i] < k){ clk++; }else{ break; } } if(clk * 2 >= rem.size()){ tc += (rem.size()+1)/2; cout << tc-1<<endl; }else{ tc += clk + (rem.size() - 2*clk); cout << tc -1 <<endl; } }else{ int rp = tc - rem.size(); int trp = rp / 3; tc -= trp; cout<<tc -1<<endl; } } }