#include<bits/stdc++.h>



using namespace std;
#define ll long long int
const long double scale = 1e+6;

long double check(int c, int m, int p, int v)
{
	long double ans = p/scale;
	
	if(c>0)
	{
		if(c>v)
		{
			if(m>0)
			{
				ans+= (c/scale)*(1+ check(c-v, m+v/2, p+ v/2,v));
			}
			else
			{
				ans+= (c/scale)*(1+ check(c-v, 0, p+v,v));
			}
		}
		else
		{
				if(m>0)
			{
				ans+= (c/scale)*(1+ check(0, m+c/2, p+ c/2,v));
			}
			else
			{
				ans+= (c/scale)*(1+ check(0, 0, p+c,v));
			}
		}
	}
	if(m>0)
	{
			if(m>v)
		{
			if(c>0)
			{
				ans+= (m/scale)*(1+ check(c+v/2, m-v, p+ v/2,v));
			}
			else
			{
				ans+= (m/scale)*(1+ check(0, m-v, p+v,v));
			}
		}
		else
		{
				if(c>0)
			{
				ans+= (m/scale)*(1+ check(c + m/2, 0, p+ m/2,v));
			}
			else
			{
				ans+= (m/scale)*(1+ check(0, 0, p+m,v));
			}
		}
	}
	return ans;
}
void solve()
{

	/*	
	int n;
	cin>>n;
	string s;
	cin>>s;
	int c = 0;
	for(int i=0; i<n; i++)
	{
		if(s[i] == 'G')
		c++;
	}
	int count=0;
	int maxi = INT_MIN,ans=0;
	for(int i=0; i<n; i++)
	{
		if(s[i]=='S' && count==1 && c>0)
		{
			count==0;
			ans=0;
			}	
		else if(s[i] == 'S' && c>0 && c-ans>0){
			count++;
			ans++;
		}
		else if(s[i] == 'G' && c>0 && c-ans>0)
		{
			ans++;
		}
		if(maxi<ans)
		maxi= ans;
	}
	cout<<maxi;
	*/
	long double p1,q,r,s;
	cin>>p1>>q>>r>>s;
	int c= round(p1*scale);
	int m = round(q*scale);
	int p = round(r*scale);
	int v = round(s*scale);
	
	long  double ans = check(c,m,p,v);
	cout<<setprecision(12)<<fixed<<ans<<endl;
			
		
	
	
		
	
}


int main()
{
	// solve();
	
	 int t;
	cin>>t;
	while(t--)
	{

		solve();
	
	
	
		
		
	}

	return 0;
		
}
