#include<bits/stdc++.h>
using namespace std;
int t,n=1000000000;
double d,m,p,v;
double f(double a,double b,double c,double r,double j) {
	double s=0;
	if((int)(a*n)>(int)(v*n))
		if((int)(b*n)>0) s+=f(a-v,b+v/2,c+v/2,r*a,j+1);
		else s+=f(a-v,0,c+v,r*a,j+1);
	else if((int)(a*n)>0)
		if((int)(b*n)>0) s+=f(0,b+a/2,c+a/2,r*a,j+1);
		else s+=f(0,0,c+a,r*a,j+1);
	if((int)(b*n)>(int)(v*n))
		if((int)(a*n)>0) s+=f(a+v/2,b-v,c+v/2,r*b,j+1);
		else s+=f(0,b-v,c+v,r*b,j+1);
	else if((int)(b*n)>0)
		if((int)(a*n)>0) s+=f(a+b/2,0,c+b/2,r*b,j+1);
		else s+=f(0,0,c+b,r*b,j+1);
	return c*j*r+s;
}
int main() {
	cin>>t;
	while(t--) {
		cin>>d>>m>>p>>v;
		printf("%.12lf\n",f(d,m,p,1,1));
	}
	return 0;
}
