#include <bits/stdc++.h>
using namespace std;
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("fast-math")
// #pragma GCC optimize(2)
// #pragma GCC optimize("Ofast","inline","-ffast-math")
// #pragma GCC optimize "-O3"

using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vll = vector<ll>;
using ld = long double;

const ll INF = 100000000000;
const ld EPS = 0.000001;

vector<ld> temp(4);
vector<bool> temp2(2);

void recalc(vector<ld> weights, vector<bool> forb, int i) {
    int another = 0;
    if (i == 0)
        another = 1;

    for (int i = 0; i < 2; ++i)
        temp2[i] = forb[i];

    temp[3] = weights[3];

    if (weights[3] > weights[i] - EPS) { //i should became unavaliable
        temp[i] = 0;
        temp2[i] = 1;

        if (!forb[another]) {
            temp[another] = weights[another] + weights[i] / 2;
            temp[2] = weights[2] + weights[i] / 2;
        } else {
            temp[2] = weights[2] + weights[i];
        }

    } else { // i is still avaliable
        if (!forb[another]) {
            temp[another] = weights[another] + weights[3] / 2;
            temp[2] = weights[2] + weights[3] / 2;
        } else {
            temp[2] = weights[2] + weights[3];
        }
        temp[i] = weights[i] - weights[3];        
    }
    
}

ld sum(vector<ld> weights, vector<bool> forb, int depth, ld div) {

    ld ans = 0;

    for (int i = 0; i < 2; ++i) {
        if (!forb[i]) {
            recalc(weights, forb, i);
            ans += sum(temp, temp2, depth + 1, div * weights[i]);
        }
    }

    ans += div * depth * weights[2];
    return ans;

}

void solve() {
    vector<ld> weights(4);
    vector<bool> forb(2);

    for (int i = 0; i < 4; ++i) cin >> weights[i];

    cout << sum(weights, forb, 1, 1) << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    cin >> t;
    cout << fixed << setprecision(10);
    
    while (t--) {
        solve();
        // if (solve())
        //    cout << "Yes" << endl;
        // else
        //    cout << "No" << endl;
    }

    return 0;
}