#include <bits/stdc++.h>

using namespace std;

#define int long long int
#define mod 1000000007
#define pi (3.141592653589)
#define ii pair<int, int>
#define vii vector<ii>
#define vi vector<int>
#define ub  upper_bound
#define lb  lower_bound
#define foi for(i=0 ; i<n ;i++)
#define foj for(j=0 ; j<n ;j++)
#define fauto(e, n) for(auto &e:n)
#define f(i, a,  n, b ) for(i=a; i<n ; i+=b)
#define all(v)  v.begin(), v.end()

/****************************************************************************************************/
const long double eps = 1e-9;
const long double scale = 1e+6;

long double expectedRaces(int c,int m,int p,int v){
    long double ans = p/scale;
    if(c>0){
        if(c>v){
            if(m>0) ans += (c/scale)*(1+expectedRaces(c-v,m+v/2,p+v/2,v));
            else ans += (c/scale)*(1+expectedRaces(c-v,0,p+v,v));
        }
        else{
            if(m>0)  ans += (c/scale)*(1+expectedRaces(0,m+c/2,p+c/2,v));
            else  ans += (c/scale)*(1+expectedRaces(0,0,p+c,v));
        }
    }
    if(m>0){
        if(m>v){
            if(c>0) ans += (m/scale)*(1+expectedRaces(c+v/2,m-v,p+v/2,v));
            else  ans += (m/scale)*(1+expectedRaces(0,m-v,p+v,v));
        }
        else{
            if(c>0)  ans += (m/scale)*(1+expectedRaces(c+m/2,0,p+m/2,v));
            else  ans += (m/scale)*(1+expectedRaces(0,0,p+m,v));
        }
    }
    return ans;
}

void solve(){
    long double cd,md,pd,vd;    cin >> cd >> md >> pd >> vd;
    int c = round(cd*scale), m = round(md*scale), p = round(pd*scale), v = round(vd*scale);
    long double ans = expectedRaces(c,m,p,v);
    cout << setprecision(12) << fixed << ans << '\n';
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin >> t;
    while (t--)
        solve();

    return 0;
}