## CPC '21 Contest 1 P1 - AQT and Fractions

View as PDF

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Authors:
Problem type

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

is a multiple of .

#### 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, .