#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long double ld;
typedef long long ll;
#define deb(x) cout<< #x << " = "<<print(x);
#define MOD 1000000007

void print(vector<int> vec)
{
	cout << "{";
	for (int i = 0;i < vec.size();i++)
	{
		cout << vec[i] << " ";
	}

	cout << "}\n";
}

void print(int x)
{
	cout << x << "\n";
}
void print(string x)
{
	cout << x << "\n";
}
void print(char x)
{
	cout << x << "\n";
}


ld ans = 0;
void solving(ld c, ld m, ld p, ld v, int steps, ld sum)
{


	if (c < 0.0000001)c = 0;
	if (m < 0.0000001)m = 0;


	ans += (sum * p) * steps;


	ld cash = c;
	ld mpound = m;
	ld pink = p;

	if (c != 0)
	{
		if (m != 0)
		{
			if (c > v)
			{
				m += v / 2;
				p += v / 2;
				c -= v;
			}
			else
			{

				m += c / 2;
				p += c / 2;
				c = 0;
			}
		}
		else
		{
			if (c > v)
			{
				p += v;
				c -= v;
			}
			else
			{

				p += c;
				c = 0;
			}
		}


		solving(c, m, p, v, steps + 1, sum * cash);
	}
	c = cash, m = mpound, p = pink;
	if (mpound != 0)
	{
		if (cash != 0)
		{
			if (mpound > v)
			{
				cash += v / 2;
				pink += v / 2;
				mpound -= v;
			}
			else
			{
				cash += mpound / 2;
				pink += mpound / 2;
				mpound = 0;
			}
		}
		else
		{
			if (mpound > v)
			{
				pink += v;
				mpound -= v;
			}
			else {
				pink += mpound;
				mpound = 0;
			}
		}
		solving(cash, mpound, pink, v, steps + 1, sum * m);
	}
}

void solve()
{
	ld c, m, p, v;

	cin >> c >> m >> p >> v;
	ans = 0;
	ld sum = 1;

	solving(c, m, p, v, 1, sum);

	cout << ans << "\n";
}

int main()
{
	cout << fixed << setprecision(10);
	int TC;
	cin >> TC;
	while (TC--)
	{
		solve();
	}
}
