AlgoUniversity
  • Go Back
Discussion
Give CashBack :

Author

Lokesh

Difficulty Level : Medium

Submissions : 1000

Asked In : Flipkart

Marks :10

: 13 | : 1

An E-commerce company is planning to give cash back. For an order with order ID $$$P$$$ of amount $$$Q$$$, it gives cash back equal to the number of operations needed to make P equal to Q. The allowed operations are:

1) $$$P=P+P$$$

2) $$$P=P-P$$$

3) $$$P=P*P$$$

4) $$$P = P/P$$$

If such a transformation is not possible, then output $$$-1$$$.

Input

First line contains number of test cases $$$T$$$, $$$1 \le T \le 10^5$$$

Next $$$T$$$ lines contain two integers $$$P$$$ and $$$Q$$$ , $$$1 \le P,Q \le 10^9$$$

Output

For each test case output the minimum number of operations needed to make $$$P$$$ equal to $$$Q$$$ , if that is not possible output $$$-1$$$

Example

Input
5
1 2
2 1
5 3
5 100
9 9
Output
1
1
-1
2
0

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.