#include <bits/stdc++.h>
 
#define ll long long
#define maxi(a, b) (a > b ? a : b)
#define mini(a, b) (a < b ? a : b)
#define MOD 1000000007

const double epsilon = 1e-10;

using namespace std;

double solve(double c, double m, double p, double v) {

	//cout << c << endl;
	double res = p;
	//cout << setprecision(12) << res << endl;

	if(abs(m) > epsilon) {

		if(abs(c) < epsilon) {
			double d = mini(v, m);
			res += m * (1+solve(0, m-d, p+d, v));
		}
		else {
			double d = mini(v, m);
			res += m * (1+solve(c+d/2, m-d, p+d/2, v));
		}

	}
	//cout << setprecision(12) << res << endl;
	if(abs(c) > epsilon) {

		if(abs(m) < epsilon) {
			double d = mini(v, c);
			res += c * (1+solve(c-d, 0, p+d, v));
		}
		else {
			double d = mini(v, c);
			res += c * (1+solve(c-d, m+d/2, p+d/2, v));
		}

	}
	//cout << setprecision(12) << res << endl;
	
	return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
	//freopen("test_input.txt","r",stdin);

	ll t = 1;
	cin >> t;
	while(t--) {
		ll n, a, b;
		double c, m, p, v;
		
		cin >> c >> m >> p >> v;
		
		cout << setprecision(12) << solve(c, m, p, v) << endl;

	}
	return 0;

}