Perry and Doof have \(a\) and \(b\) chocolates respectively (where \(a > b\)). Doof has a special device Moduloinator in which he can set the value of \(M\) between \(1\)and \(a\). And when he pushes the button, the number of chocolates that Perry has becomes \(a \,{mod}\, M\).Specifically new value of \(a\) becomes \(a \,{mod}\, M\).
He can use the device as many times as he wants, and also he can change the value of \(M\) every time.
Is Doof’s device useful enough to exactly equalize the chocolates of him and Perry?
Input Format
-
First-line contains integer \(T\), the number of test cases.
-
Next \(T\) lines contain two integers \(a\) and \(b\).
Output Format
-
For every test case output, the minimum number of times Doof needs to use the device to equalize the chocolates or print \(-1\) if not possible.
Constraints
-
\(1 \leq T \leq 10\)
- \(1 \leq b < a \leq 10^6\)
- For the first test case, you can set the value of \(M\) as 2 and can equalize the value of \(a\) and \(b\) by using the device once.
- For the second test case, it's not possible to equalize the values.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor