#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define F first
#define S second

const int INF = 1e18;
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int k;
		cin>>k;
		vector<int>d(n);
		for(int i = 0;i<n;i++)cin>>d[i];
		sort(d.begin(),d.end());
		int l = 0;
		int r = n;
		while(l<=r){
			int mid = (l+r)/2;
			int m = n-mid;
			int boxes = 0;
			set<pair<int,int>>s;
			for(int j = 0;j<m;j++){
				s.insert({d[j],j});
			}
			vector<int>used(m,0);
			for(int i = m-1;i>=0;i--){
				s.erase({d[i],i});
				if(used[i])continue;
				if(d[i]>=k){
					boxes = INF;
					break;
				}
				auto it = s.upper_bound({k-d[i],INF});
				if(it!=s.begin()){
					it--;
					s.erase(it);
					used[(*it).S] = 1;
				}
				boxes++;				
			}
			if(boxes>mid)l = mid+1;
			else r = mid-1;
		}
		cout<<l-1<<endl;
	}
}