spoj#SIRNUMS. SIR CHIRAG AND MAGIC NUMBERS
SIR CHIRAG AND MAGIC NUMBERS
Sir Chirag is famous for his 'Intelligencia". He found that Dukkar and Chapta were unable to solve a question.
The magic Numbers are described as: The numbers are strictly positive, don't contain any leading zeroes. It has exaclty 'p' digits and if we move the last digit of the number to the beginning, it grows exactly 'x' times.
Chirag Sir took the task to solve it. It took him minutes to solve. Now its your turn.
You have to find the Minimum possible number that satisfies the above conditions Given 'p' and 'x'.
Input
First line contains the number of test cases T: 0<T<=50
Next T lines contains two intergers p and x
0<p<=1000000 and 0<x<10
Output
If such a number is not possible then print "Impossible" (Without the quotes). else print the number.
Example
Input: 3
6 5
1 2
6 4</p>Output: 142857
Impossible
102564
(observe that for the first test case : 142857x5 = 714285)