#include <bits/stdc++.h>
typedef long long LL;
#define deb(x) std::clog << (#x) << " = " << (x) << '\n';
#define PII pair<int,int>
#define endl '\n'
typedef long double ld;
using namespace std;
double eps = 1e-7;
ld ans, v;
void dfs(ld c, ld m, ld p, ld chance) {
    ans += chance;
    if(c < eps && m < eps) return;
    if(c > eps) {
        ld del = min(c, v);
        if(m > eps) { // m != 0 分配给 m , p
            dfs(c - del, m + del/2, p + del/2 , chance * c);
        } else {
            dfs(c - del, m, p + del, chance * c);
        }
    }
    if(m > eps) {
        ld del = min(m, v);
        if(c > eps) {
            dfs(c + del/2, m - del, p + del/2, chance * m);
        } else {
            dfs(c, m - del, p + del, chance * m);
        }
    }
}
void solve() {
    ans = 0;
    ld c, m, p; cin >> c >> m >> p >> v;
    dfs(c, m, p, 1);
    cout << fixed << setprecision(12) << ans << endl;
}
int main(){
    //srand(time(NULL) * time(NULL));
    ios::sync_with_stdio(false); cin.tie(0);
    int t ; cin >> t; while(t--)
    solve(); return 0;
}   