#include <bits/stdc++.h>
#define db double
#define ll long long
#define int ll
#define vi vector<int>
#define vii vector<vi >
#define pii pair<int, int>
#define mkp make_pair
#define pb push_back
#define Case(x) cout << "Case #" << x << ": "
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
db ans;
int mx = 0;
bool equ(db a, db b) {
	return abs(a-b) < 1e-12;
}
void rec(db c, db m, db p, db v, db now, int x, int tot) {
	mx = max(mx, tot);
	ans += now * p * tot;
	if (x == 1) {
		return;
	}
	if (c > 0) {
		if (c < v || equ(c, v)) {
			if (x == 2) {
				rec(0, 0, 1, v, now*c, x-1, tot+1);
			} else {
				rec(0, m+c/2, p+c/2, v, now*c, x-1, tot+1);
			}
		} else {
			if (x == 2) {
				rec(c-v, 0, p+v, v, now*c, x, tot+1);
			} else {
				rec(c-v, m+v/2, p+v/2, v, now*c, x, tot+1);
			}
		}
	}
	if (m > 0) {
		if (m < v || equ(m, v)) {
			if (x == 2) {
				rec(0, 0, 1, v, now*m, x-1, tot+1);
			} else {
				rec(c+m/2, 0, p+m/2, v, now*m, x-1, tot+1);
			}
		} else {
			if (x == 2) {
				rec(0, m-v, p+v, v, now*m, x, tot+1);
			} else {
				rec(c+v/2, m-v, p+v/2, v, now*m, x, tot+1);
			}
		}
	}
}
signed main(){
#ifdef _DEBUG
	freopen("out", "w", stdout);
#endif
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	int T;
	cin >> T;
	while (T--) {
		ans = 0;
		mx = 0;
		db c, m, p, v;
		cin >> c >> m >> p >> v;
		rec(c, m, p, v, 1, 3, 1);
		printf("%.12lf\n", ans);
		//cout << mx << '\n';
		//cout << ans << '\n';
	}
	return 0;
}

