#include<stdio.h>
//#include<conio.h>
void ascend(int *a,int n)
{
int i,j,temp;
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
void result(int *p, int *r,int n)
{
int i,count_p=0,count_r=0,output=0;
for(i=0;i<n;i++)
{
if(p[count_p]<=r[count_r])
{
output++;
count_p++;
count_r++;
}
else
count_r++;
}
printf("%d",output);
}
int main()
{
int t,n,i,j;
int *rack,*pie;
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%d",&n);
rack=(int *)malloc(n*sizeof(int));
pie=(int *)malloc(n*sizeof(int));
for(j=0;j<n;j++)
{
scanf("%d",&pie[j]);
}
for(j=0;j<n;j++)
{
scanf("%d",&rack[j]);
}
ascend(pie,n);
ascend(rack,n);
result(pie,rack,n);
}
}