Problem Description
Given a positive integer N, you’re to solve the following problem:
Find a positive multiple of N, says M, that contains minimal number of different digits in base-K notation. If there’re several solutions, you should output the numerical smallest one. By saying numerical smallest one, we compar their numerical value, so 0xAhex < 11dec.
You may assume that 1 <= N <= 104 and 2 <= K <= 10.
Input
There’re several (less than 50) test cases, one case per line.
For each test case, there is a line with two integers separated by a single space, N and K.
Please process until EOF (End Of File).
Output
For each test case, you should print a single integer one line, representing M in base-K notation,the answer.
Sample Input
10 8
2 3
7 5
Sample Output
2222
2
111111