#include <bits/stdc++.h>
#define ll long long int
 
using namespace std;

const long double scale = 1e+6;
 
void init_code(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output6.txt", "w", stdout);
	#endif
}

long double solve(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+solve(c-v,m+v/2,p+v/2,v));
            else
                ans += (c/scale)*(1+solve(c-v,0,p+v,v));
        }
        else
        {
            if(m>0)
                ans += (c/scale)*(1+solve(0,m+c/2,p+c/2,v));
            else
                ans += (c/scale)*(1+solve(0,0,p+c,v));
        }
    }
    if(m>0)
    {
        if(m>v)
        {
            if(c>0)
                ans += (m/scale)*(1+solve(c+v/2,m-v,p+v/2,v));
            else
                ans += (m/scale)*(1+solve(0,m-v,p+v,v));
        }
        else
        {
            if(c>0)
                ans += (m/scale)*(1+solve(c+m/2,0,p+m/2,v));
            else
                ans += (m/scale)*(1+solve(0,0,p+m,v));
        }
    }
    return ans;
}

int main(){
	init_code();

	int t;
	cin >> t;

	while(t--){
		long double cd, md, pd, vd;
		cin >> cd >> md >> pd >> vd;

		int c = round(cd * scale);
		int m = round(md * scale);
		int p = round(pd * scale);
		int v = round(vd * scale);

		long double ans = solve(c, m, p, v);

		cout << setprecision(12) << fixed << ans << endl;

	}
}