#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const double esp=1e-14;
char s[maxn];
double v,r=0;
void fun(double c,double m,double p,int len,double cup)
{
    if(c>esp)
    {
        double d=max(c-v,(double)0.0);
        if(m>esp)
            fun(d,m+(c-d)/2,p+(c-d)/2,len+1,cup*c);
        else
            fun(d,m,p+(c-d),len+1,cup*c);
    }
    if(m>esp)
    {
        double d=max(m-v,(double)0.0);
        if(c>esp)
            fun(c+(m-d)/2,d,p+(m-d)/2,len+1,cup*m);
        else
            fun(c,d,p+m-d,len+1,cup*m);
    }
    r+=p*cup*(len+1);
}
void ans()
{
    double c,m,p;
    r=0;
    cin>>c>>m>>p>>v;
    fun(c,m,p,0,1.0);
    printf("%.6f\n",r);
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ans();
    }
    return 0;
}
