#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

const int N = 2e5 + 5;

#define eps 1e-8

ld v, ans;


void solve(int idx, ld c, ld m, ld p, ld prob){
    ans += (prob * p * idx);
    if(c > eps){
        if(m > eps) solve(idx + 1, c - v, m + min(c, v) / 2, p + min(c, v) / 2, prob * c);
        else solve(idx + 1, c - v, m, p + min(c, v), prob * c);
    }
    if(m > eps){
        if(c > eps) solve(idx + 1, c + min(m, v) / 2, m - v, p + min(m, v) / 2, prob * m);
        else solve(idx + 1, c, m - v, p + min(m, v), prob * m);
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int tt;
    cin >> tt;
    while(tt--){
        ld c, m, p;
        cin >> c >> m >> p >> v;
        ans = 0;
        solve(1, c, m, p, 1);
        cout << fixed << setprecision(8) << ans << '\n';

    }


    return 0;
}

