#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;

double out = 0;
const double e = 0.0000001;

void pro(double c, double m, double p, double v, int step, double step_pro)
{
    out += p * step * step_pro;
    //cout << "test:" << setw(7) << c << setw(7) << m << setw(7) << p << setw(7) << inip << setw(7) << step << setw(7) << step_pro << endl;

    if(c == 0);
    else if(c > v+e && m != 0)
        pro(c-v, m+v/2, p+v/2, v, step+1, step_pro*c);
    else if(c <= v+e && m != 0)
        pro(0, m+c/2, p+c/2, v, step+1, step_pro*c);
    else if(c > v+e && m == 0)
        pro(c-v, 0, p+v, v, step+1, step_pro*c);
    else
        pro(0, 0, p+c, v, step+1, step_pro*c);

    if(m == 0);
    else if(m > v+e && c != 0)
        pro(c+v/2, m-v, p+v/2, v, step+1, step_pro*m);
    else if(m <= v+e && c != 0)
        pro(c+m/2, 0, p+m/2, v, step+1, step_pro*m);
    else if(m > v+e && c == 0)
        pro(0, m-v, p+v, v, step+1, step_pro*m);
    else
        pro(0, 0, p+m, v, step+1, step_pro*m);
}

int main()
{
    double c, m, p, v;
    int t;
    scanf("%d", &t);
    for(int i = 0; i < t; i++)
    {
        scanf("%lf %lf %lf %lf", &c, &m, &p, &v);
        out = 0;
        pro(c, m, p, v, 1, 1);
        printf("%.12lf", out);
        if(i != t - 1)
            printf("\n");
    }
    return 0;
}
