Start

2019-03-18 13:00 UTC

Kattis Set 09

End

2019-03-25 09:29 UTC
The end is near!
Contest is over.
Not yet started.
Contest is starting in -317 days 6:49:05

Time elapsed

164:29:59

Time remaining

0:00:00

Problem A
Candy Distribution

Kids like candies, so much that they start beating each other if the candies are not fairly distributed. So at your next party, you better start thinking before you buy the candies.

If there are $K$ kids, you of course need $K \cdot X$ candies for a fair distribution, where $X$ is a positive natural number. But you learned that always at least one kid loses one candy, so you better be prepared with exactly one spare candy, resulting in $(K \cdot X) + 1$ candies.

Usually, the candies are packed into bags with a fixed number of candies $C$ per bag. You will buy some of these bags so that the above constraints are fulfilled.

Input

The first line gives the number of test cases $t$ ($0 < t < 100$). Each test case is specified by two integers $K$ and $C$ on a single line, where $K$ is the number of kids and $C$ the number of candies in one bag ($1 \le K, C \le 10^9$). As your money is limited, you will never buy more than $10^9$ candy bags.

Output

For each test case, print one line. If there is no such number of candy bags to fulfill the above constraints, print “IMPOSSIBLE”. Otherwise print the number of candy bags you want to buy. If there is more than one solution, any will do.

Sample Input 1 Sample Output 1
5
10 5
10 7
1337 23
123454321 42
999999937 142857133
IMPOSSIBLE
3
872
14696943
166666655