#include<bits/stdc++.h>
using namespace std;
#define re register int
#define int long long
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f==1?x:-x;
}
const double eps=1e-10;
double c,m,p,v;
double dfs(double c,double m,double p,int dep)
{
	double tmp=p*dep;
	if(c>eps && c>v)
	{
		if(m<eps) tmp+=c*dfs(c-v,0,p+v,dep+1);
		else tmp+=c*dfs(c-v,m+v/2,p+v/2,dep+1);
	}
	else if(c>eps && c<=v)
	{
		if(m<eps) tmp+=c*dfs(0,0,1,dep+1);
		else tmp+=c*dfs(0,m+c/2,p+c/2,dep+1);
	}
	if(m>eps && m>v)
	{
		if(c<eps) tmp+=m*dfs(0,m-v,p+v,dep+1);
		else tmp+=m*dfs(c+v/2,m-v,p+v/2,dep+1);
	}
	else if(m>eps && m<=v)
	{
		if(c<eps) tmp+=m*dfs(0,0,1,dep+1);
		else tmp+=m*dfs(c+m/2,0,p+m/2,dep+1);
	}
	return tmp;
}
signed main()
{
	int T=read();
	while(T--)
	{
		cin>>c>>m>>p>>v;
		printf("%.12lf\n",dfs(c,m,p,1));
	}
	return 0;
}
