#include <bits/stdc++.h>
using namespace std;
#define Input(v, n) fr(i, n) cin >> v[i];
#define checkk(v, n) fr(i, n) cout << v[i] << " " << endl;
#define sort(v) sort(v.begin(), v.end());
#define int long long int
#define double long double
#define fr(i, n) for (int i = 0; i < n; i++)
#define frr(i, s, e) for (int i = s; i <= e; i++)
#define rfr(i, s, e) for (int i = s; i >= e; i--)
#define fix(f,n) fixed<<setprecision(n)<<f
#define endl "\n"
#define pb push_back
#define mp make_pair
#define mod 1000000007

int test;
double v,ans;

void add(double &c,double &m,double &p,int i,double t){
   if(i==0){
       if(m==0) p+=t;
       else {
           t=t/2.0;
           m+=t,p+=t;
       }
   }
   else{
       if(c==0) p+=t;
       else {
           t=t/2.0;
           c+=t,p+=t;
       }
   }
}

void calc(double c,double m,double p,double val,double count){
    if(c<0.000001) c=0;
    if(m<0.000001) m=0;

    double t1=c,t2=m,t3=p;
    ans+=(count*(val*p));
    
    if(c!=0){
        double nan=val*c;
        if(c<=v) add(c,m,p,0,c),c=0,calc(c,m,p,nan,count+1.0);
        else  add(c,m,p,0,v),c=c-v,calc(c,m,p,nan,count+1.0);
    }
    c=t1,m=t2,p=t3;
    if(m!=0){
        double nan=val*m;
        if(m<=v) add(c,m,p,1,m),m=0,calc(c,m,p,nan,count+1.0);
        else  add(c,m,p,1,v),m=m-v,calc(c,m,p,nan,count+1.0);
    }
    
}

void solve()
{   
    ans=0.0;
    double c,m,p;
    cin>>c>>m>>p>>v;
    calc(c,m,p,1.0,1.0);
    cout<<fix(ans,12)<<endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
     
    cin>>test;
    //test=1;
    while (test--)
    {
        solve();
    }

    return 0;
}