ChefX showed ChefY his new pizza slice design. The design is a planar figure that can be drawn in the following way:
Draw a point A0 and two rays from this point such that the angle between them is α<π/2.
Mark N points A
1,A
2,A
3,…,A
N on one ray in this order (A
1 is closest to A
0).
Mark N points B
1,B
2,B
3,…,B
N on the other ray in this order (B
1 is closest to A
0).
For each valid i, draw a line segment between points A
i and B
i+1.
For each valid i, draw a line segment between points B
i and A
i+1.
Finally, draw a line segment between points A
N and B
N.
All these 2N−1 line segments must have equal lengths, which must also be equal to |A
0A
1|=|A
0B
1|.
The result should look roughly like this:
ChefY wants to show ChefX that he does not know his own design very well. He asks ChefX to compute the angle between three of the marked points in this figure. It is clear that there are only four types of angles:
∠A
xA
yB
z
∠A
xB
yA
z
∠A
xB
yB
z
∠B
xA
yB
z
Can you help ChefX find the angle ChefY asks for? It can be proved that under the given constraints, each angle can be written as π⋅m/n, where m and n are coprime integers; you should find m and n.
Example Input
1
175456798 1 151163203 151163204 151163205
Example Output
66583464 116971199
Explanation
Example case 1: The type is 1, so the angle we want is A
151163203A
151163204B
151163205. The angle is (66583464/116971199)π≐1.7883.
Problem Link :
https://www.codechef.com/JAN19A/problems/XYPIZQ