
// Problem : C. Need for Pink Slips
// Contest : Codeforces - Codeforces Round #730 (Div. 2)
// URL : https://codeforces.com/contest/1543/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<long long, long long>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

const int p = 1e9 + 7;
const int lim = 2004;
const long double ep = 1e-6;

void pre_io(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
}

long double player2(long double a, long double p, long double v, int rc){
	long double res = p*(rc+1);
	if(a-v<ep)
		res += a*(rc+2);
	else
		res += a*player2(a-v, p+v, v, rc+1);
	return res;
}

long double player3(long double c, long double m, long double p, long double v, int rc){
	long double res = p*(rc+1);
	if(c-v<ep)
		res += c*player2(m+(c/2), p+(c/2), v, rc+1);
	else
		res += c*player3(c-v, m+(v/2), p+(v/2), v, rc+1);
	if(m-v<ep)
		res += m*player2(c+(m/2), p+(m/2), v, rc+1);
	else
		res += m*player3(c+(v/2), m-v, p+(v/2), v, rc+1);
	
	return res;
}

int32_t main()
{
	pre_io();
	int test;
	cin>>test;
	while(test--){
		long double c, m, p, v;
		cin>>c>>m>>p>>v;
		long double res = player3(c,m,p,v, 0);
		cout<<setprecision(10)<<res<<"\n";
	}
}