#include <bits/stdc++.h>

using ll=long long;
#define MOD 1000000007

using namespace std;

void calc(double c, double m, double p, double v, double *exp, double prob, int n, int x){
    if(x==1){
        prob *= p;
        *exp += prob*n;
        return;
    }
    else if(x>1){
        double prob1 = prob;
        prob1 *= p;
        *exp += prob1*n;
        if(c>0){
            double prob2 = prob;
            prob2 *= c;
            if(c-v>1e-7){
                calc(c-v, ((m==0)?(0):(m+(v/2))), ((m==0)?(p+v):(p+(v/2))), v, exp, prob2, n+1, x);
            }
            else{
                calc(0, ((m==0)?(0):(m+(c/2))), ((m==0)?(p+c):(p+(c/2))), v, exp, prob2, n+1, x-1);
            }
        }
        if(m>0){
            double prob3 = prob;
            prob3 *= m;
            if(m-v>1e-7){
                calc(((c==0)?(0):(c+(v/2))), m-v, ((c==0)?(p+v):(p+(v/2))), v, exp, prob3, n+1, x);
            }
            else{
                calc(((c==0)?(0):(c+(m/2))), 0, ((c==0)?(p+m):(p+(m/2))), v, exp, prob3, n+1, x-1);
            }
        }
        return;
    }
    else return;
}

void solve() {
    // Write your solution here
    double c, m, p, v;
    cin>>c>>m>>p>>v;
    double exp = 0.0;
    int n = 1;
    int x=3;
    calc(c, m, p, v, &exp, 1, 1, x);
    cout<<setprecision(10)<<exp<<"\n";
    return ;
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int t = 1;
    cin >> t;  // Comment out if single test case
    while (t--) {
        solve();
    }

    return 0;
}