409064: GYM103428 J Circular Billiard Table

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Circular Billiard Tabletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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?

Input

The 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}$$$.

Output

For 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$$$.

ExampleInput
2
45 1
60 1
Output
3
2
Note

The example is shown in the following figure:

加入题单

算法标签: