#include<bits/stdc++.h>

using namespace std;

#define fo(i, n) for(i=0;i<n;i++)

void find_prob(double a, double b, double c, double v, double &initial , double &final,double cnt,double ans) {
	initial = final;
	final += ans*cnt*c;
	// cout << ans*cnt*c << " ";
	if(abs(a)<0.000000001) {
		cnt++;
		// cout << "b" <<b << " ";
		while((b-v)>0 && abs(b-v)>0.000000001) {
			// cout << "b" <<b << " ";
			ans = ans*b;
			c+=v;
			final+= ans*cnt*c;
			cnt++;
			b-=v;
			// cout << ans*cnt*c << " ";
		}
		// cout << " b" << b << " ";
		final += ans*b*1*cnt;
		return;
	}
	if(abs(b)<0.000000001) {
		cnt++;
		while((a-v)>0 && abs(a-v)>0.000000001) {
			ans = ans*a;
			c+=v;
			final += ans*cnt*c;
			cnt++;
			a-=v;
		}
		final += ans*a*1*cnt;
		return;

	}
	// if(abs(c-1)<0.00000001) {
	// 	// cout << "icanalso reach here";
	// 	final += ans*cnt;
	// 	return;
	// }
	if(abs(final-initial) < 0.0000000001) {
		return;
	}
	// cout << "a " << a <<" b " << b << " ";
	if(a>0){
		// cout << "in a ";
		if(a-v>0)find_prob(a-v,b+v/2,c+v/2,v,initial,final,cnt+1,ans*a);
		else find_prob(0,b+a/2,c+a/2,v,initial,final,cnt+1,ans*a);
	}
	if(b>0){
		// cout << "iamere ";
		if(b-v>0)find_prob(a+v/2,b-v,c+v/2,v,initial,final,cnt+1,ans*b);
		else find_prob(a+b/2,0,c+b/2,v,initial,final,cnt+1,ans*b);
	}
}

void solve() {
	double a,b,c,v;
	cin >> a>>b>>c>>v;
	double initial =10000;
	double final =0;
	double error = 0.0000001;
	int cnt = 1;
	// while(abs(final - initial) < error) {

	// }
	find_prob(a,b,c,v,initial,final,1,1);
	cout. precision(10);
	cout << final << "\n";


}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int tc = 1;
    cin >> tc;
    while(tc--) {
        solve();
    }

}