Problem
Stack likes the number a lot.
He has two non-negative integers and .
In one operation, Stack can do either of the following:
- (change to )
- (change to )
Note that denotes absolute value of . For example and .
Find the minimum number of operations after which at least one integer out of and becomes divisible by .
Input Format
- The first line of input contains a single integer , denoting the number of test cases. The description of test cases follows.
- The only line of each test case contains two integers and .
Output Format
For each test case, output in a single line the minimum number of operations after which at least one integer out of and becomes divisible by .
Constraints
Sample 1:
Input
Output
2 0 343 1 1
0 1
Explanation:
Test case : is already divisible by .
Test case : In the only operation, Stack can change to . Now is divisible by .
No comments:
Post a Comment