#include <bits/stdc++.h>

using namespace std;

#define debug(x) cerr << #x << " = " << x << endl
#define boost ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) { cout << endl; }

template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

template<typename T>
inline void read(T& x) {
    x = 0; T f = 1; char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

template<typename T, typename ...Args>
inline void read(T& x, Args&... args) { read(x), read(args...); }

constexpr int MAXN = 2e5 + 5, MOD = 1e9 + 7;
constexpr long double EPS = 1e-10;

long double c, m, p, v;
inline long double Search(long double c, long double m, long double p) {
    long double ans = p * 1.0;
    if (c > EPS) {
        if (c > v + EPS) {
            if (m > EPS) {
                ans += c * (1.0 + Search(c - v, m + v / 2, p + v / 2));
            } else {
                ans += c * (1.0 + Search(c - v, .0, p + v));
            }
        } else {
            if (m > EPS) {
                ans += c * (1.0 + Search(.0, m + c / 2, p + c / 2));
            } else {
                ans += c * (1.0 + Search(.0, .0, p + c));
            }
        }
    }
    if (m > EPS) {
        if (m > v + EPS) {
            if (c > EPS) {
                ans += m * (1.0 + Search(c + v / 2, m - v, p + v / 2));
            } else {
                ans += m * (1.0 + Search(.0, m - v, p + v));
            }
        } else {
            if (c > EPS) {
                ans += m * (1.0 + Search(c + m / 2, .0, p + m / 2));
            } else {
                ans += m * (1.0 + Search(.0, .0, p + m));
            }
        }
    }
    return ans;
}

signed main() {
    boost;
    cout << setprecision(6) << fixed;
    int tc;
    cin >> tc;
    while (tc--) {
        cin >> c >> m >> p >> v;
        cout << Search(c, m, p) << "\n";;
    }
    return 0;
}
/* stuff you should look for
 * int overflow, array bounds
 * special cases (n = 1?)
 * do smth instead of nothing and stay organized
 * WRITE STUFF DOWN
 * DON'T GET STUCK ON ONE APPROACH
 */