AQT is studying fractions and he has encountered problems. In each problem, AQT is given a fraction with a numerator and a denominator . AQT wants to know after converting the fraction to a decimal and removing all terminating zeroes, how many digits there are to the right of the decimal. Can you help AQT answer all problems?
Constraints
For all subtasks:
Subtask 1 [10%]
Subtask 2 [10%]
is a multiple of .
Subtask 3 [30%]
Subtask 4 [50%]
No additional constraints.
Input Specification
The first line contains , the number of problems you need to help AQT solve.
The next lines contain and , the numerator and the denominator of the fraction, respectively.
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