#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ul ;
typedef long long ll ;
//typedef pair<ll, ll>  p ;
//typedef pair< p , ll > edge ;
//#define Euc_D(x1,y1,x2,y2) (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)
#define vi vector< ll >
#define vl vector< ll >
#define sci(x) ll x; scanf("%d",&x)
#define scu(x) ul x ; scanf("%llu", &x)
#define scl(x) ll x ; scanf("%lld", &x)
#define pr(x) prllf("%llu", x)
#define rep(i , a , b , n) for(ll i = a; i < b ; i += n )
#define f first
// #define s second
#define pb push_back
#define mp make_pair
#define tc(t) scu(t); while ( t-- )
#define nl '\n'
#define MOD 1000000007
// just type fast; at the beginning to do both these
#define fast ios::sync_with_stdio(false); cin.tie(0)
#define inf 0x3f3f
double ans,v;
double e = 1e-12;
void solve(double c, double m,  double p, double prev, int r){
    //cout<<c<<" "<<m<<" "<<p<<" "<<r<<"\n";
    if(abs(c-0.0)<=e&&abs(m-0.0)<=e){
        ans += (double)r*prev;
        return;
    }
    else{
        ans += (double)r*p*prev;
        if(abs(c-0.0)>e){
            double dis = c-max(0.0,c-v);
            if(abs(m-0.0)>e)
                solve(max(0.0,c-v),m+dis/2.0,p+dis/2.0,prev*c,r+1);
            else
                solve(max(0.0,c-v),m,p+dis,prev*c,r+1);
        }
        if(abs(m-0.0)>e){
            double dis = m-max(0.0,m-v);
            if(abs(c-0.0)>e)
                solve(c+dis/2.0,max(0.0,m-v),p+dis/2.0,prev*m,r+1);
            else
                solve(c,max(0.0,m-v),p+dis,prev*m,r+1);
        }
    }
    return;
}
int main()
{
    fast;
    ll T;
    cin>>T;
    //T = 1;
    for(ll t=1;t<=T;t++){
       double c,m,p;
       cin>>c>>m>>p>>v;
       ans = 0;
       solve(c,m,p,1.0,1);
       cout<<setprecision(8)<<ans<<"\n";
    }

    return 0;
}


