#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <unordered_set>
using namespace std;
const double eps=1e-12;
typedef long long ll;
double v,res;
void solve(double c,double m,double p,int t,double tot){
    if(p<eps)return;
    if(c>eps){
        double d = c>=v?v/2:c/2;
        if(m>eps)solve(c-2*d,m+d,p+d,t+1,tot*c);
        else solve(c-2*d,m,p+2*d,t+1,tot*c);
    }
    if (m>eps){
        double d = m>=v?v/2:m/2;
        if(c>eps)solve(c+d,m-2*d,p+d,t+1,tot*m);
        else solve(c,m-2*d,p+2*d,t+1,tot*m);
    }
    if (p>eps){
        res += t*p*tot;
    }

}
int main (){
    int t;
    scanf("%d",&t);
    double c,m,p;
    while (t--&&scanf("%lf%lf%lf%lf",&c,&m,&p,&v)==4){
        res = 0;
        solve(c,m,p,1,1);
        printf("%lf\n",res);
    }
    return 0;
}