AQT is studying fractions and he has encountered
Constraints
For all subtasks:
Subtask 1 [10%]
Subtask 2 [10%]
Subtask 3 [30%]
Subtask 4 [50%]
No additional constraints.
Input Specification
The first line contains
The next
Output Specification
For each problem, output the answer to the problem if the answer is finite, or -1
if the answer is infinite.
Sample Input 1
4
1 3
2 5
3 9
1 4
Sample Output 1
-1
1
-1
2
Explanation for Sample 1
For the first test case,
For the second test case,
For the third test case,
For the fourth test case,
Comments