#include<bits/stdc++.h>
#define ll long long int
#define nl "\n"
#define vec vector<ll>
#define pb push_back
#define MOD 1000000007
#define test ll testc;cin>>testc;while(testc--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
ll bpow(ll a,ll b) {ll ans=1;while (b>0){if (b&1) ans=(ans*a)%MOD;b/=2;a=(a*a)%MOD;}return ans;}
double ans=0;
void rp(double c,double m,double p,double v, int n,double pp)
{
	n++;
	ans+=(double(n)*p*pp);
	//cout<<(double(n)*p*pp)<<endl;
	//cout<<ans<<endl;
	//cout<<p<<" "<<pp<<endl;
	if (c-0>0.000000001)
	{
		//ans+=pp*c*(double)n;
		double temp=pp*c;
		double z=min(c,v);
		double tt=z;
		//c-=z;
		//double xx=0;
		if (m-0>0.0000001) m=m+z/2,z-=z/2;
		//cout<<p+z/2<<endl;
		//p+=z;
		
		rp(c-tt,m,p+z,v,n,temp);
		if (m-0>0.00000001) m=m-z;
	}
	if (m-0>0.00000001)
	{
		//ans+=pp*c*(double)n;
		pp*=m;
		double z=min(m,v);
		m-=z;
		//double xx=0;
		if (c-0>0.0000001) c=c+z/2,z-=z/2;
		//cout<<p+z/2<<endl;
		p+=z;
		
		rp(c,m,p,v,n,pp);
	}

}
int main()
{
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	#endif
    	test
    	{
    		ans=0;
    		double c,m,p,v;
    		cin>>c>>m>>p>>v;
    		double pp=1;
    		rp(c,m,p,v,0,pp);
    		//cout<<"ans"<<nl;
    		cout<<setprecision(12)<<ans<<endl;
    	}
    	
}
