#include <bits/stdc++.h>

using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<string> VS;
 
#define FOR(x, b, e) for (int x = b; x <= (e); ++x)
#define FORD(x, b, e) for (int x = b; x >= (e); --x)
#define REP(x, n) for (int x = 0; x < n; ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(c) ((int)(c).size())
#define PB push_back
const int INF = 100000001;
const double EPS = 10e-8;

double exps = 0.0;

bool eq(double a, double b) {
    return abs(a-b) < EPS;
}

bool is_zero(double x) {
    return eq(x, 0.0);
}

void draw(double c, double m, double p, double v, double cp=1.0, int step=0, string s=string{}) {
    if (!is_zero(c)) {
        double nc = max(0.0, c-v);
        double nm = m;
        double np = p;
        if (is_zero(nm)) {
            np = p + (c-nc);
        } else {
            np = p + (c-nc)/2.0;
            nm = m + (c-nc)/2.0;
        }
        draw(nc, nm, np, v, cp*c, step+1, s+string("c"));
    }
    if (!is_zero(m)) {
        double nc = c;
        double nm = max(0.0, m-v);
        double np = p;
        if (is_zero(nc)) {
            np = p + (m-nm);
        } else {
            np = p + (m-nm)/2.0;
            nc = c + (m-nm)/2.0;
        }
        draw(nc, nm, np, v, cp*m, step+1, s+string("m"));
    }
    exps += (step+1)*cp*p;
}

void solve() {
    double c, m, p, v;
    cin >> c >> m >> p >> v;
    exps = 0.0;
    draw(c, m, p, v);
    cout << fixed << setprecision(16) << exps << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    REP(j, t) {
        solve();
    }
}
