#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
#define pb push_back
#define rall(x) x.rbegin(),x.rend()
const int N=1,mod=998244353,MOD=1e9+7,INF=1e18,inf=1e9;
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int testcasescount=1;
cin>>testcasescount;
while(testcasescount--){
int n,k,sum=0,cnt=0;
cin>>n>>k;
int a[n],b[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++){
cin>>b[i];
}
sort(a,a+n);
sort(b,b+n);
reverse(b,b+n);
int j=0,ans=0;
bool ch=true;
for(int i=0;i<n;i++){
if(a[i]+1>k){
break;
}
int y=k%((k/(a[i]+1))+1);
if(y==0){
break;
}
while(j<n&&b[j]>y){
j++;
if(j==n){
ch=false;
break;
}
else if(j<n&&y>=b[j]){
break;
}
}
if(!ch){
break;
}
else{
j++;
ans++;
}
}
cout<<ans<<'\n';
}
}
//Allahu Akbar
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk9mYXN0IikKI3ByYWdtYSBHQ0MgdGFyZ2V0KCJzc2Usc3NlMixzc2UzLHNzc2UzLHNzZTQscG9wY250LGFibSxtbXgsYXZ4LHR1bmU9bmF0aXZlIikKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBpbnQgbG9uZyBsb25nCiNkZWZpbmUgYWxsKHgpIHguYmVnaW4oKSx4LmVuZCgpCiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgcmFsbCh4KSB4LnJiZWdpbigpLHgucmVuZCgpCmNvbnN0IGludCBOPTEsbW9kPTk5ODI0NDM1MyxNT0Q9MWU5KzcsSU5GPTFlMTgsaW5mPTFlOTsKc2lnbmVkIG1haW4oKXsKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoTlVMTCk7CiAgICAvL2ZyZW9wZW4oImlucHV0LnR4dCIsInIiLHN0ZGluKTsKICAgIC8vZnJlb3Blbigib3V0cHV0LnR4dCIsInciLHN0ZG91dCk7CiAgICBpbnQgdGVzdGNhc2VzY291bnQ9MTsKICAgIGNpbj4+dGVzdGNhc2VzY291bnQ7CiAgICB3aGlsZSh0ZXN0Y2FzZXNjb3VudC0tKXsKICAgICAgICBpbnQgbixrLHN1bT0wLGNudD0wOwogICAgICAgIGNpbj4+bj4+azsKICAgICAgICBpbnQgYVtuXSxiW25dOwogICAgICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgICAgICBjaW4+PmFbaV07CiAgICAgICAgfQogICAgICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgICAgICBjaW4+PmJbaV07CiAgICAgICAgfQogICAgICAgIHNvcnQoYSxhK24pOwogICAgICAgIHNvcnQoYixiK24pOwogICAgICAgIHJldmVyc2UoYixiK24pOwogICAgICAgIGludCBqPTAsYW5zPTA7CiAgICAgICAgYm9vbCBjaD10cnVlOwogICAgICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgICAgICBpZihhW2ldKzE+ayl7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBpbnQgeT1rJSgoay8oYVtpXSsxKSkrMSk7CiAgICAgICAgICAgIGlmKHk9PTApewogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgd2hpbGUoajxuJiZiW2pdPnkpewogICAgICAgICAgICAgICAgaisrOwogICAgICAgICAgICAgICAgaWYoaj09bil7CiAgICAgICAgICAgICAgICAgICAgY2g9ZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlIGlmKGo8biYmeT49YltqXSl7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYoIWNoKXsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2V7CiAgICAgICAgICAgICAgICBqKys7CiAgICAgICAgICAgICAgICBhbnMrKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb3V0PDxhbnM8PCdcbic7CiAgICB9Cn0KLy9BbGxhaHUgQWtiYXIK