Sohel sir gave an assignment in CSE-315 course instead of a class test. The assignment was
to make questions and provide corresponding answers from the chapters 2, 3, 4, 5. Each
student is assigned chapter no y according to the formula:
y = (Roll % 4) + 2
I.e. he has to make questions and answers from chapter y. According to this rule, Roll 4 was
supposed to make questions and answers from chapter 2 as (4 % 4) + 2 = 2 and Roll 35 was
assigned to chapter 5 as (35 % 4) +2 = 5. In the meantime, roll 35 had already made the
questions & answers from chapter 5 and Roll 4 got the complete assignment of roll 35. So to
copy that assignment Roll 4 wanted to change the divisor 4 of the formula to some number m
such that his assignment changes to chapter 5 , that is (4 % m) + 2 = 5. But he failed to find
such number. Now, your problem is similar to the above problem.
Given two number x and y you have to find a positive number m such that (x % m) + 2 = y.
If multiple m is possible, choose the minimum one. If no answer is found print `Impossible'.
First line of input will contain the number of test cases, T125. Then there follows T lines,
each containing two integers x (
0x1012) and y (
2yx + 2).
For each case, print m, if m is found. Otherwise print `Impossible' (without quotes). See the
samples given below for exact formatting.
4
4 5
35 5
4 2
11 5
Impossible
4
1
4
Problem Setter: Mohammad Hafiz Uddin
Alternate Solution: Radi Muhammad Reza