#include< stdio.h>
#include < stdlib.h>
main()
{
int t,i,j;
scanf("%d",&t);
int x[t],y[t],s1[t],s2[t],m[t],k[t],z[t];
int a[t][10],b[t][10],n[t];
for(i=0;i<t;i++)
{
scanf("%d%d%d",&n[i],&x[i],&y[i]);
for(j=0;j<n[i];j++)
scanf("%d",&a[i][j]);
for(j=0;j<n[i];j++)
scanf("%d",&b[i][j]);
}
for(i=0;i<t;i++)
{
s1[i]=0;
s2[i]=0;
for(j=0;j<n[i];j++)
{
s1[i]=s1[i]+a[i][j];
s2[i]=s2[i]+b[i][j];
}
m[i]=(s1[i]>=s2[i])?s2[i]:s1[i];
z[i]=n[i]*x[i]-m[i];
k[i]=(y[i]+m[i])/x[i];
if(z[i]<=0)
{
z[i]=0;
k[i]=n[i];
}
printf("%d",k[i]);
printf(" ");
printf("%d",z[i]);
printf("\n");
}
}