#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define FILES freopen("in", "r", stdin); freopen("out", "w", stdout);
#define vec vector<int>
using namespace std;

long double s = 0;
int scale = 1e6;
void bkt(long double * v, long double j = 1, int ind = 1) {
    long double k[4] = {0};
    if(v[0] != 0 && v[1] != 0) {
        k[3] = v[3];
        if(v[0] > v[3]) {
            k[0] = v[0] - v[3];
            k[1] = v[1] + v[3] / 2;
            k[2] = v[2] + v[3] / 2;
        } else {
            k[1] = v[1] + v[0] / 2;
            k[2] = v[2] + v[0] / 2;
        }
        bkt(k, j * v[0] / scale, ind + 1);
    } else if(v[0] != 0) {
        k[3] = v[3];
        if(v[0] > v[3]) {
            k[0] = v[0] - v[3];
            k[2] = v[2] + v[3];
        } else {
            k[2] = v[2] + v[0];
        }
        bkt(k, j * v[0] / scale, ind + 1);
    }
    if(v[0] != 0 && v[1] != 0) {
        k[3] = v[3];
        if(v[1] > v[3]) {
            k[1] = v[1] - v[3];
            k[0] = v[0] + v[3] / 2;
            k[2] = v[2] + v[3] / 2;
        } else {
            k[1] = 0;
            k[0] = v[0] + v[1] / 2;
            k[2] = v[2] + v[1] / 2;
        }
        bkt(k, j * v[1] / scale, ind + 1);
    } else if(v[1] != 0) {
        k[3] = v[3];
        if(v[1] > v[3]) {
            k[1] = v[1] - v[3];
            k[2] = v[2] + v[3];
        } else {
            k[1] = 0;
            k[2] = v[2] + v[1];
        }
        bkt(k, j * v[1] / scale, ind + 1);
    }
    s += j * v[2] * ind;
}

void tc() {
    long double v[4];
    s = 0;
    for(int i = 0; i < 4; i++)
        cin >> v[i], v[i] *= scale;
    bkt(v);
    cout << s / scale << '\n';
}

signed main() {
    cout << setprecision(12) << fixed;
    int t;
    cin >> t;
    while(t--)
        tc();
    return 0;
}