ZOJ Problem Set - 3596
Given an integer n and an integer m, please calculate the minimal multiple of n which consists of exactly m different digits.
This problem has several test cases. The first line of the input is an integer T (0 < T ≤ 150) indicates the number of test cases. Each test case is a line of 2 integers n (0 < n ≤ 1000) and m (0 < m ≤ 10)
For each test case, if you can find the minimal multiple of n and x satisfying the above condition, please output a line as "x=n*y", otherwise output "Impossible" in a single line.
3 37 1 2 2 100 1
111=37*3 10=2*5 Impossible
Author: CAO, Peng
Contest: The 12th Zhejiang University Programming Contest