Hansel and Grethel

No attempts yetTime limit1sMemory limit128 MB

Problem

On a warm summer afternoon, Hansel and Grethel are walking together through the fields. It is getting late and, to be honest, they are lost. Grethel is a little scared, still vividly remembering the last time they got lost in the forest — an evil witch had locked them inside a house built of gingerbread and sugar! But Hansel can reassure her: this time they came prepared, with a map and a compass.

Hansel picks two clearly recognizable landmarks and uses the compass to measure the direction toward each. Grethel finds those landmarks on the map and reads off their map coordinates. From this information they can pin down their own position on the map.

You are given the coordinates of two landmarks and the compass direction (an angle measured clockwise from North) toward each landmark. Write a program that computes the coordinates of Hansel and Grethel's current position.

Input

The first line contains one positive integer: the number of situations to solve. Each situation is described by two lines, one per landmark. Each landmark line contains three integers:

  • the landmark's x-coordinate on the map (0x1000 \le x \le 100); the x-axis runs West-to-East, increasing toward the East.
  • the landmark's y-coordinate on the map (0y1000 \le y \le 100); the y-axis runs South-to-North, increasing toward the North.
  • the direction dd toward the landmark, in degrees (0d3600 \le d \le 360), measured clockwise from North: 0° = North, 90° = East, 180° = South, and so on.

Within each situation the two directions are never exactly equal and never differ by exactly 180°, so the position is always uniquely determined.

Output

For each situation, print one line with two numbers separated by a single space: the x and y coordinates of Hansel and Grethel's position, each with exactly 4 digits after the decimal point (0x,y1000 \le x, y \le 100). Round half up: if the next digit is 5 or greater round up, otherwise round down.