#include<bits/stdc++.h>
using namespace std;
#define int               long long int
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
const int N5=1e5+7,N5_2=2e5+7,N5_3=3e5+7,N6=1e6+7,N7=1e7+7,mod=1e9+7;
// int prime[N6];
long double ex=0;
long double scale=1e7;

bool comp(pair<int,int> a, pair<int,int> b){
    return a.second<b.second?1:0;
}
 
int pw(int n, int p,int M=mod){
    int val=1;
    while(p>0){
        if(p & 1){
            val= (val*n)%M;
        }
        n=(n*n)%M;
        p>>=1;
    }
    return val;
}
 
// void SieveofEratosthenes(int n=N6){
//     memset(prime,true, sizeof(prime));
//     rep(i,2,n+1){
//         if(prime[i]){
//             for(int j=i*i;j<=n;j+=i){
//                 prime[j]=false;
//             }
//         }
//     }
//     return;
// }

/*
1010
0000
1001
0000
*/

/*
57

6 6 6 6 6 6 6 5 5 5

*/

void rec(int c,int m, int p,int v,int count,long double prob){
    ex+=count*(prob==0?p/scale:prob*(p/scale));
    // cout<<"p = "<<count*(prob==0?p:prob*p)<<endl;
    if(c>v){
        // rep(i,0,count)  cout<<" ";
        // cout<<"c";
        if(m>0)
            rec(c-v,m+v/(2.0),p+v/(2.0),v,count+1,prob==0?c/scale:prob*(c/scale));
        else
            rec(c-v,0,p+v,v,count+1,prob==0?c/scale:prob*(c/scale));
    }
    else if(c>0){
        // rep(i,0,count)  cout<<" ";
        // cout<<"c";
        if(m>0)
            rec(0,m+c/(2.0),p+c/(2.0),v,count+1,prob==0?c/scale:prob*(c/scale));
        else{
            rec(0,0,p+c,v,count+1,prob==0?c/scale:prob*(c/scale));
        }
    }
    if(m>v){
        // rep(i,0,count)  cout<<" ";
        // cout<<"m";
        if(c>0)
            rec(c+v/(2.0),m-v,p+v/(2.0),v,count+1,prob==0?m/scale:prob*(m/scale));
        else{
            rec(0,m-v,p+v,v,count+1,prob==0?m/scale:prob*(m/scale));
        }
    }
    else if(m>0){
        // rep(i,0,count)  cout<<" ";
        // cout<<"m";
        if(c>0)
            rec(c+m/(2.0),0,p+m/(2.0),v,count+1,prob==0?m/scale:prob*(m/scale));
        else
            rec(0,0,p+m,v,count+1,prob==0?m/scale:prob*(m/scale));
    }
    return;
}


void solve(){
    long double cd,md,pd,vd;
    cin>>cd>>md>>pd>>vd;
    ex=0;
    int c = round(scale*cd);
    int m = round(scale*md);
    int p = round(scale*pd);
    int v = round(scale*vd);
    rec(c,m,p,v,1,0);
    cout<<ex<<endl;
    return;

}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    #ifdef SIEVE
        sieve();
    #endif
    #ifdef NCR
        init();
    #endif
    cout<<setprecision(8);
    int t=1;
    cin>>t;
    while(t--) solve();
    return 0;
}