beecrowd | 1484
# Type & Add

**Timelimit: 3**

Por Ricardo Anido Brazil

Strike Boy, as the name suggests, is a boy fanatic for all types of computer games. He is going on vacation in a paradise island where computers are not allowed. He had a great time playing with games on his cell phone, but now the battery is dead and since there is no electricity on the island, he stopped playing. Strike Boy then decided to invent a new hobby, using the keypad of his cell phone. In this new game, for two players, one chooses two integers *S* and *D*. The opposing player must then find a sequence of terms such that:

- Each term of the sequence is a number with
*D*decimal digits, except for the last term, which can have between 1 and*D*digits; - The sum of all terms of the sequence is equal to
*S*; - The digits used to form a term correspond to the keys of a standard cell phone keyboard ('0 'to '9');
- Each digit is used at most once in the sequence;
- The first term of a sequence can begin with any digit, but the order of the digits of the sequence when read from left to right, is such that the next key always corresponds to a key that is immediately adjacent to the previously used key (vertically, horizontally or diagonally).

For example, if * S * = 230 and * D * = 3, there are only two possible solutions obeying the rules of the game : [074, 156] and [085, 142, 3]. The sequence [230] is not a solution because the '3 'key is not a neighbor of the key '0 '.

Left picture: Keyboard illustrating the keys used to form the sequence [074, 156]

Right picture: Keyboard illustrating the keys used to form the sequence [085, 142, 3]

Help Strike Boy to check if his oponnent's answers are correct: write a program that, given * S * and * D *, print all possible solutions .

The input contains several test cases. Each test consist in just one line, containing two integers **S** and **D**, separated by an empty space, representing the desired sum and the number of digits of each term (0 ≤ **S** ≤ 10.000.000.000 and 1 ≤ **D** ≤ 10). The end of the input is specified by **S** = **D** = −1.

For each test case, your program must write one answer. The first line of an answer must contain an identifier of the test case, in the format '#i', where 'i' is initially 1 and is incremented for each test case. Then, if a solution for the problem exists, your program must display the list of the possible sequences of terms. If more than one sequence is possible, they must appear in ascending lexicographic order. Each sequence of terms must be printed in one line, with its terms separated by an empty space. If there is no solution, your program must print one line containing the word 'impossible'.

*Definition:* consider the sequences *Sa* = a_{1}a_{2 }... a* _{m}* and

- S
_{a}is an empty sequence; - a
_{1}< b_{1}; - a
_{1}= b_{1}and the sequence a_{2}a_{3}... a_{m}preceeds sequence b_{2}b_{3}... b_{n}.

Sample Input | Sample Output |

7 1 |
#1 |