One way to measure the height of a model rocket is a geodesic method. Two observers, A on the left and B on the right, stand at the two ends of a 100-meter baseline on a flat test field. The launch pad is the same distance from A and B and is 50 meters away from the baseline. Observer A's instrument is HA meters above the launch pad height, and observer B's instrument is HB meters above the launch pad height.
After the rocket is launched, it opens its parachute at its highest point and releases a large amount of smoke. Each observer measures two angles to that smoke: the elevation angle above the horizontal plane, and the azimuth angle of the vertical plane containing the line of sight. Azimuth is measured counterclockwise from the baseline direction from A to B. Let alpha be A's elevation angle, beta be B's elevation angle, gamma be A's azimuth angle, and delta be B's azimuth angle.
Use these observations as follows. Consider the two 3D lines of sight from the instruments. On each line, find the point closest to the other line. The midpoint of those two closest points is used as the estimated highest point of the rocket. The rocket height is the vertical distance from the launch pad to that estimated point.
Given HA, HB, and the four measured angles for each launch, compute the rocket height for every launch.
The first line contains the number of launches N (1 <= N <= 100), HA, and HB. All three values are real numbers except that N is an integer.
Each of the next N lines contains four real numbers alpha, beta, gamma, and delta for one launch. The values alpha, beta, and gamma are between 0 and 90 degrees, inclusive. The value delta is between 90 and 180 degrees, inclusive.
For each launch, print the rocket's maximum height rounded to the nearest integer meter, one value per line.