#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
#define P push
#define B break
#define C continue
#define R return
#define gcd(x,y) __gcd(x,y)
#define be(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(be(a),x)-a.begin())
#define ub(a,x) (upper_bound(be(a),x)-a.begin())
#define uniq(a) a.resize(unique(be(a))-a.begin())
#define fast ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define po(x) (x%mod+mod)%mod
#define SM(x,y) (po(x)+po(y))%mod
#define M(x,y)  (po(x)*po(y))%mod
using namespace std;
ll t,n,i,j,k,l,r,mid,mod=1e9+7,m,ans;
ll a[400005],f[400005],c[400005];
char ch;
map<ll,ll>mp;
//set<ll>s;
string s,st;
//vector<ll>v[300005],u;
double x,y,z,v,d[105][105],eps=1e-9;
bool b[106][105];
double dp(int i,int j){
    double &ret=d[i][j];
    if(b[i][j]) R ret;
    b[i][j]=1;
    ret=0;
    double X,Y,Z;
    Z=z+((i+j)*v)/2.0;
    X=x+(j*v/2.0)-i*v;
    Y=y+(i*v/2.0)-j*v;
    if(X<eps) {
        X*=-1;
        Y-=X/2.0;
        Z-=X/2.0;
        X=1;
        for(k=1;;k++) {
            ret+=Z*X*(i+j+k);
            if(Y<eps) R ret;
            X*=Y;
            Y-=v;
            Z+=v;
            Z=min(Z,1.0);
        }
        R ret;
    }
    if(Y<eps) {
        Y*=-1;
        X-=Y/2.0;
        Z-=Y/2.0;
        Y=1;
        for(k=1;;k++) {
            ret+=Z*Y*(i+j+k);
            if(X<eps) R ret;
            Y*=X;
            X-=v;
            Z+=v;
            Z=min(Z,1.0);
        }
        R ret;
    }
    R ret=X*dp(i+1,j)+Y*dp(i,j+1)+Z*(i+j+1);
}
int ff(){
    cin>>x>>y>>z>>v;
    memset(b,0,sizeof b);
    double ans=dp(0,0);
    cout<<fixed<<setprecision(8)<<ans;
    R 0;
}
int main()
{
    fast
    cin>>t;
    while(t--){
        ff();
        cout<<"\n";
    }
}
/**

*/
