#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <cassert>
#include <string.h>

#include <time.h>
#include <random>
#include <iomanip>
using namespace std;

#define ll long long
#define N 100000

//counterclockwise direction from AB to BC
double getAngle(pair<double, double> a, pair<double, double> b, pair<double, double> c) {
    pair<double,double> v1, v2;
    
    v1 = {a.first-b.first, a.second-b.second};
    v2 = {c.first-b.first, c.second-b.second};
    
    double dot = v1.first*v2.first + v1.second*v2.second;
    double det = v1.first*v2.second - v1.second*v2.first;
    
    return atan2(det, dot);
}

void solve() {
    ll j, p, H, L;
    cin >> j >> p >> H >> L;

    double g = 9.81;
    double vo = sqrt(2*g*j);
    
    double low = 0;
    double high = 100000000;

    ll iters = 0;
    ll maxIters = 100;
    
    while (iters < maxIters) {
        double l = low+(high-low)/2;
        
        double fH = (-g/2)*(l/vo)*(l/vo)+H+p;   //flight height
        double sH; //ski height
        
        if (l < 0) {
            sH = H;
        } else if (l >= 0 && l < L/2) {
            sH = H * (1 - 2*(l/L)*(l/L));
        } else if (l >= L/2 && l < L) {
            sH = 2*H* (l/L - 1) * (l/L - 1);
        } else if (l >= L) {
            sH = 0;
        }
        
        if (fH > sH) {
            low = l;
        }
        else {
            high = l;
        }
        iters++;
    }
    
    double l = low;
    double iH;  //intersect height
    iH = (-g/2)*(l/vo)*(l/vo)+H+p;
    double vx = vo;
    double vy = -1*(sqrt(2*g*(H+p-iH)));
    double landSpeed = sqrt(vx*vx+vy*vy);
    
    //angle
    double dsH;
    if (l < 0) {
        dsH = 0;
    } else if (l >= 0 && l < L/2) {
        dsH = -4 * H * l/(L*L);
    } else if (l >= L/2 && l < L) {
        dsH = 4*H* (l/L - 1) / L;
    } else if (l >= L) {
        dsH = 0;
    }
    
    double angle = getAngle({vx, vy}, {0,0}, {1, dsH});
    angle *= 180/M_PI;
    
    cout << l << " " << landSpeed << " " << angle << endl;
    
}

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    ll t;
    cin >> t;
    for (ll i = 0; i < t; i++) {
        solve();
    }
}