#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
const int MAXN = 1e5 + 6;
const double ps = 1e-7;
struct node
{
int w, v;
double p;
}S[MAXN];
bool cmp(node a, node b)
{
return a.p > b.p;
}
int main()
{
int t;
cin >> t;
while (t--)
{
int n, m;
double sum = 0.0;
cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> S[i].w;
for (int i = 0; i < n; i++)
cin >> S[i].v;
for (int i = 0; i < n; i++)
S[i].p = 1.0 * S[i].v / S[i].w;
sort(S, S + n, cmp);
for (int i = 0; i < n; i++)
{
//printf("S.p:%lf %d\n",S[i].p,S[i].w);
if (m - S[i].w <= 0)
{
sum += S[i].p * m;
break;
}
else
{
sum += S[i].v;
m -= S[i].w;
}
//printf("%d\n", m);
}
printf("%.2lf\n",sum+ps);
}
return 0;
}