#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<ld> vld;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i,l,r) for( ll i = (l) ; i < (r) ; i++ )
#define forb(i,r,l) for( ll i = (r) ; i >= (l) ; i-- )
#define sz(x) (int)x.size()
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define cntbit(x) __builtin_popcount(x)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

const int N = 1e6+7;
const int MOD = 1e9 + 7;
const ll INF = 1e9;
const ld eps = 1e-9;

double c, m, p, v;
double ans = 0;

void dfs(double cc, double cm, double cp, double cost, int race = 1) {
  if (cc >= v) {
    double ccm = 0, ccp = 0;

    if (cm > eps) {
      ccp = cp + v / 2;
      ccm = cm + v / 2;
    }
    else {
      ccp = cp + v;
    }

    dfs(cc - v, ccm, ccp, cost * cc, race + 1);
  }
  else if (cc > eps) {
    double ccm = 0, ccp = 0;

    if (cm > eps) {
      ccp = cp + cc / 2;
      ccm = cm + cc / 2;
    }
    else {
      ccp = cp + cc;
    }
    dfs(0, ccm, ccp, cost * cc, race + 1);
  }
  ///--------------------------------------------------------------------
  if (cm >= v) {
    double ccc = 0, ccp = 0;
    if (cc > eps) {
      ccc = cc + v / 2;
      ccp = cp + v / 2;
    }
    else {
      ccp = cp + v;
    }
    dfs(ccc, cm - v, ccp, cost * cm, race + 1);
  }
  else if (cm > eps) {
    double ccc = 0, ccp = 0;
    if (cc > eps) {
      ccp = cp + cm / 2;
      ccc = cc + cm / 2;
    }
    else ccp = cp + cm;
    dfs(ccc, 0, ccp, cost * cm, race + 1);
  }

  ans += cost * race * cp;
  return;
}

void solve() {
  cin >> c >> m >> p >> v;
  ans = 0;
  dfs(c, m, p, 1, 1);
  cout << fixed << setprecision(9) << ans << endl;
}

int main() {
  fastIO;
  #ifndef ONLINE_JUDGE
  freopen("test.inp", "r", stdin);
  #endif

  int tc = 1;
  cin >> tc;
  while (tc--) {
    solve();
  }
}

/* stuff you should look for
    - int overflow, array bounds
    - special cases (n=1?)
    - do smth instead of do nothing and stay organized
    - WRITE STUFF DOWN
    - DONT JUST STICK ON ONE APPROACH
*/
