/* ***** *   * *     ***** *****       ***** *   *     *    *   *
     *   *   * *     *       *         *     *   *    * *   *   *
     *   *   * *     *****   *         ***** *****   *****  *****
     *   *   * *         *   *             * *   *  *     * *   *
     *   ***** ***** ***** ***** ***** ***** *   * *       **   *
/********************************DAIICT****************************/
/********************************INDIA*****************************/
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long  int
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
#define ff first
#define ss second
#define fix fixed<<setprecision (15)
const int mod=1e9+7;
const int nax=1e6+10;
ll i,j,x,l,y,z,k;
long double P=pow(10,6);
long double dfs(long double c,long double m,long double p,long double v)
{
    long double ans=(p/P);
   // deb3(c,m,p)

  if(c>0){
    if(c>v)
    {
        if(m>0)
        {
            ans+=(c/P)*(1+dfs(c-v,m+(v/2),p+(v/2),v));
        }
        else
        {
            ans+=(c/P)*(1+dfs(c-v,m,p+(v),v));
        }
    }
    else
    {
        if(m>0)
        {
            ans+=(c/P)*(1+dfs(0,m+(c/2),p+(c/2),v));
        }
        else
        {
            ans+=(c/P)*(1+dfs(0,0,p+(c),v));
        }
    }
  }
  if(m>0){
   if(m>v)
    {
        if(c>0)
        {
            ans+=(m/P)*(1+dfs(c+(v/2),m-v,p+(v/2),v));
        }
        else
        {
            ans+=(m/P)*(1+dfs(0,m-v,p+(v),v));
        }
    }
    else
    {
        if(c>0)
        {
            ans+=(m/P)*(1+dfs(c+(m/2),0,p+(m/2),v));
        }
        else
        {
            ans+=(m/P)*(1+dfs(0,0,p+(m),v));
        }
    }
  }

  return ans;
}
void solve()
{
   long double c,m,p,v;
   cin>>c>>m>>p>>v;
   c=c*P;
   m=m*P;
   p=p*P;
   v=v*P;
   double final=dfs(c,m,p,v);
   cout<<fix<<final<<endl;
   return ;
}
int main(){
    FAST

    ll t1=1;
    cin>>t1;



            while(t1--)
            {
                solve();

            }
            return 0;
}
