#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define MOD 1000000007
#define endl '\n'

long double solve(long double c, long double m, long double p, long double v)
{
	int x = 1;
	if (m > 1e-6)
		x++;
	if (c > 1e-6)
		x++;

	long double ans = p * 1;

	long double nc, nm, np;

	if (c > 1e-6)
	{
		if (c <= v)
		{
			nc = 0;
			nm = ((m > 1e-6) ? m + c / (x - 1) : 0);
			np = p + c / (x - 1);
		}
		else
		{
			nc = c - v;
			nm = ((m > 1e-6) ? m + v / (x - 1) : 0);
			np = p + v / (x - 1);
		}
		ans += c * (1 + solve(nc, nm, np, v));
	}

	if (m > 1e-6)
	{
		if (m <= v)
		{
			nm = 0;
			nc = ((c > 1e-6) ? c + m / (x - 1) : 0);
			np = p + m / (x - 1);
		}
		else
		{
			nm = m - v;
			nc = ((c > 1e-6) ? c + v / (x - 1) : 0);
			np = p + v / (x - 1);
		}
		ans += m * (1 + solve(nc, nm, np, v));
	}

	// cout << c << ' ' << m << ' ' << p << ' ' << x << ' ' << ans << endl;

	return ans;
}

void run()
{
	long double c, m, p, v;
	cin >> c >> m >> p >> v;
	int x = 1;
	if (c)
		x++;
	if (m)
		x++;
	// cout << solve(c, m, p, v) << endl;
	long double ans = solve(c, m, p, v);
	printf("%.10Lf\n", ans);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tichnas;
	cin >> tichnas;
	while (tichnas--)
		run();
	return 0;
}