Limits 2s, 512 MB

ABCD is a convex quadrilateral. E, F, G, H are the midpoints of AB, BC, CD and DA respectively. EP and HP are the angle bisectors of ∠FEH and ∠EHG. x and y are the lengths of HP and EP. θ is equal to ∠BAD.

Your task is very simple. You are given the lengths of AB, BC, CD, DA and the angle θ. Find x and y.

Input

Input starts with an integer T (≤ 10^5), denoting the number of test cases.

Each test case contains five integers AB, BC, CD, DA (1 ≤ AB, BC, CD, DA ≤ 10000) and θ in degrees (0 < θ < 180).

You can safely assume that every given quadrilateral is valid.

Output

For each case, print a single line containing two floating point numbers which denote the values of x and y. Errors less than 10^-6 will be ignored.

Sample

InputOutput
2
2 2 2 2 90
2 2 2 2 45
1 1
0.5411961001 0.5411961001

Submit

Login to submit.

Statistics

62% Solution Ratio
Baka_RaffiEarliest, Jan '18
steinumFastest, 0.0s
steinumLightest, 5.5 kB
Baka_RaffiShortest, 628B
Toph uses cookies. By continuing you agree to our Cookie Policy.