#include <stdio.h>
int main()
{
int T, n, m, i, j;
double a[100], b[100], c[100];
double sum, x, y, z;
scanf("%d" ,&T);
while (T--)
{
sum = 0;
scanf("%d %d", &n, &m);
for (i = 0; i < n; i++)
scanf("%lf", &a[i]);
for (i = 0; i < n; i++)
scanf("%lf", &b[i]);
for (i = 0; i < n; i++)
c[i] = b[i] * 1.0 / a[i];
for (i = 0; i < n; i++)
{
for (j = i; j < n; j++)
{
if (c[i] < c[j])
{
x = a[i];
a[i] = a[j];
a[j] = x;
y = b[i];
b[i] = b[j];
b[j] = y;
z = c[i];
c[i] = c[j];
c[j] = z;
}
}
}
for (i = 0; i < n; i++)
{
if (m > a[i])
{
sum += b[i];
m -= a[i];
}
else
{
sum += m * c[i];
break;
}
}
printf("%.2lf\n", sum + 1e-7);
}
return 0;
}