#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>
#include<queue>
#include<iterator>
#include<unordered_map>
#define dbg(x) cout<<#x<<" = "<<x<<endl;
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define eps 1e-8
 
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int maxn = 200100;
const int mod = 1000000007;
double dfs(double c, double m, double p, double v, int step);

int main()
{
    int t, n, i, j, k;
    scanf("%d", &t);
    while(t--){
        double c, m, p, v;
        scanf("%lf %lf %lf %lf", &c, &m, &p, &v);
        printf("%.10lf\n", dfs(c, m, p, v, 1));
    }
    return 0;
}

double dfs(double c, double m, double p, double v, int step){
    double ans = 0;
    if(c > eps){
        double x = min(v, c);
        if(m > eps)
            ans += c*(dfs(c-x, m+x/2, p+x/2, v, step+1)+1);
        else 
            ans += c*(dfs(c-x, 0, p+x, v, step+1)+1);
    }
    if(m > eps){
        double x = min(v, m);
        if(c > eps)
            ans += m*(dfs(c+x/2, m-x, p+x/2, v, step+1)+1);
        else 
            ans += m*(dfs(0, m-x, p+x, v, step+1)+1);
    }
    ans += p;
    return ans;
}