#include<iostream>
#include<iomanip>
using namespace std;
#define d double
d f(d c, d m, d p, d v) {
    d ans = 1, i = 2, e, a, b, g, q = 1e-8;
    for (; i--; swap(c, m))
        if (c > q) {
            e = c < v ? c : v; b = c - v; g = p + e / 2; a = m + e / 2;
            if (m < q)g = p + e, a = m;
            ans += c * f(b, a, g, v);
        }
    return ans;
}
int main() {
    d c, m, p, v;
    int t;
    cin >> t;
    while (t--)
    {
        cin >> c >> m >> p >> v;
        cout << setprecision(10) << f(c, m, p, v) << endl;
    }
   
    return 0;
}