409064: GYM103428 J Circular Billiard Table
Description
Mr. JR is an expert billiard player who has won the championship of BBPC (Billiard Ball Playing Contest). Nowadays, Mr. JR is tired of the ordinary rectangular billiards table and has great interest in the circular billiards table. Specifically, he is thinking about the following problem.
Mr. JR puts a white ball on the edge of the circular billiard table, and uses the club to hit the white ball at the angle of $$$\beta\ (0 < \beta < 90)$$$. He wants to know how many times the white ball will collide with the edge of the circular billiard table before it returns to the origin for the first time.
The collision between the ball and the table conforms to the law of mechanics, that is, relative to the tangent of the collision point on the table edge, the incident angle $$$\alpha_1$$$ is equal to the exit angle $$$\alpha_2$$$ (as shown in figure (b)). And there will be no energy loss in the collision (that means the friction between the ball and the table is not considered, as shown in figure (a)).
This problem is too difficult for Mr. JR. Can you help him?
InputThe first line contains an integer $$$T\ (1 \le T \le 10^4)$$$, denoting the number of test cases.
The only line of each test case contains two space-separated integers $$$a$$$ and $$$b$$$ ($$$0 < a, b \le 10^9,\ 0 < \frac{a}{b} < 90$$$), denoting the value of $$$\beta = \frac{a}{b}$$$.
OutputFor each test case, output a single line containing the answer to the corresponding test case. If the white ball can never return to the origin, output $$$-1$$$.
ExampleInput2 45 1 60 1Output
3 2Note
The example is shown in the following figure: