#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define eps 1e-9
long double b[50005], h[50005], w[50005], d[50005];
bool possible(ll n, long double wl, long double mid)
{
long double volume=0;
for(ll i=0;i<n;i++)
{
if(b[i]<mid)
{
volume+=(min(mid-b[i], h[i])*d[i]*w[i]);
}
}
if(volume+eps<wl)
return true;
return false;
}
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
for(ll i=0;i<n;i++)
{
cin>>b[i]>>h[i]>>w[i]>>d[i];
}
long double wl;
cin>>wl;
long double start=1, end=(4*(1e6)), ans=4*(1e6);
while(fabs(start-end)>eps)
{
long double mid=(start+end)/2;
if(possible(n, wl, mid))
{
ans=mid;
start=mid;
}
else
{
end=mid;
}
}
if(start>3*(1e6))
cout<<"OVERFLOW"<<endl;
else
printf("%0.2lF \n", start);
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBlcHMgMWUtOQpsb25nIGRvdWJsZSBiWzUwMDA1XSwgaFs1MDAwNV0sIHdbNTAwMDVdLCBkWzUwMDA1XTsKYm9vbCBwb3NzaWJsZShsbCBuLCBsb25nIGRvdWJsZSB3bCwgbG9uZyBkb3VibGUgbWlkKQp7Cglsb25nIGRvdWJsZSB2b2x1bWU9MDsKCWZvcihsbCBpPTA7aTxuO2krKykKCXsKCQlpZihiW2ldPG1pZCkKCQl7CgkJCXZvbHVtZSs9KG1pbihtaWQtYltpXSwgaFtpXSkqZFtpXSp3W2ldKTsKCQl9Cgl9CglpZih2b2x1bWUrZXBzPHdsKQoJcmV0dXJuIHRydWU7CglyZXR1cm4gZmFsc2U7Cn0KaW50IG1haW4oKQp7CglsbCB0OwoJY2luPj50OwoJd2hpbGUodC0tKQoJewoJCWxsIG47CgkJY2luPj5uOwoJCWZvcihsbCBpPTA7aTxuO2krKykKCQl7CgkJCWNpbj4+YltpXT4+aFtpXT4+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