#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn = 110;
const double ps = 1e-7;
struct tt{
int m;
int p;
double av;
};
tt a[maxn];
bool cmp(tt a, tt b){
return a.av > b.av;
}
int main(){
int T;
scanf("%d", &T);
while (T--){
double pp = 0;
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++)
scanf("%d", &a[i].m);
for (int i = 0; i < n; i++)
scanf("%d", &a[i].p);
for (int i = 0; i < n; i++)
a[i].av = (double)a[i].p / (double)a[i].m;
sort(a, a + n, cmp);
for (int i = 0; i < n; i++){
if (m <= 0)
break;
if (m >= a[i].m){
m -= a[i].m;
pp += a[i].p;
}
else{
pp += a[i].av*m;
m = 0;
}
//printf("%d %.2lf**\n", m, pp);
}
printf("%.2lf\n", pp+ps);
}
return 0;
}