#include<bits/stdc++.h>
using namespace std;

#define int long long
int mod = 1e9 + 7;
int inf = 1e17;


double solve (double c, double m, const double v)
{
	//cout<<c<<" "<<m<<endl;
	if(c<1e-12) c= 0.0;
	if(m<1e-12) m =0.0;
	double ans = 1-c-m;
	double new_c,new_m,new_p;
	if(c>0)
	{
		new_c = c - min(c,v);
		new_m = (m>0)?(m + min(c,v)/2):0.0;
		ans += c*(1+solve(new_c,new_m,v));
	}
	if(m>0)
	{
		new_c = (c>0)?(c + min(m,v)/2):0.0;
		new_m = m - min(m,v);
		ans += m*(1+solve(new_c,new_m,v));
	}
	return ans;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t; 
	cin>>t;
	while(t--)
	{
		double c,m,p,v;
		cin>>c>>m>>p>>v;	
		double ans = solve(c,m,v);
		cout<<setprecision(15)<<ans<<endl;
	}	
}