#include<cstdio>
#include<vector>
#include<queue>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;
constexpr int N = 1e6 + 5;
constexpr int INF = 1e9;
constexpr double EPS = 1e-8;

int T, n;
double ans, v;

bool sml(double a, double b) {
    return a - b < EPS;
}

void dfs(double c, double m, int cnt, double g) {
//    printf("%d %lf\n", cnt, (1 - c - m) * g);
	ans += (1 - c - m) * g * (cnt + 1);
    if(c == 0 && m == 0) {
        return ;
    }
    if(c != 0) {
        if(sml(c, v)) {
            dfs(0, m == 0 ? 0 : m + c / 2, cnt + 1, g * c);
        } else {
            dfs(c - v, m == 0 ? 0 : m + v / 2, cnt + 1, g * c);
        }
    } 
    if(m != 0) {
        if(sml(m, v)) {
            dfs(c == 0 ? 0 : c + m / 2, 0, cnt + 1, g * m);
        } else {
            dfs(c == 0 ? 0 : c + v / 2, m - v, cnt + 1, g * m);
        }
    }
}

int main() {
    scanf("%d", &T);
    while(T--) {
        double c, m, p;
        ans = 0;
        scanf("%lf%lf%lf%lf", &c, &m, &p, &v);
        dfs(c, m, 0, 1);
        printf("%.10lf\n", ans);
    }
}