#include <cstdio>

using namespace std;

typedef long long ll;

const double delta = 1e-6;

double ans, v;

double min(double a, double b)
{
	if (a <= b)	return a;
	return b;
}

void dfs(double c, double m, double p, double limit, int num)
{
	double temp = limit * p * num;
	ans += temp;
	if (c == 0 && m == 0)
		return;
	if (c >= delta)
	{
		double temp = min(c, v);
		if (m >= delta)	dfs(c - temp, m + temp / 2, p + temp / 2, limit*c, num + 1);
		else    dfs(c - temp, 0, p + temp, limit*c, num + 1);
	}
	if (m >= delta)
	{
		double temp = min(m, v);
		if (c >= delta)	dfs(c + temp / 2, m - temp, p + temp / 2, limit*m, num + 1);
		else    dfs(0, m - temp, p + temp, limit*m, num + 1);
	}
}

void solve()
{
	ans = 0;
	double c, m, p;
	scanf("%lf%lf%lf%lf", &c, &m, &p, &v);
	dfs(c, m, p, 1, 1);
	printf("%.12lf\n", ans);
}

int main()
{
	int t;
	scanf("%d", &t);
	while (t)
	{
		solve();
		t--;
	}
	return 0;
}
