Welcome to ZOJ
Information
Select Problem
Runs
Ranklist
ZOJ Problem Set - 3449
Doraemon's Number Game III

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Doraemon likes to play number game with Nobita.

One day, Doraemon came up with an idea, he gave a number a in base 10 and a number x (x < 10), and then he let Nobita multiplies the first digit of a with x and add the second digit of a, then multiplies x again and add the third digit of a. Do the above rules until there is only one digit (the leftmost digit of a is called the first digit).

For example, let a = 123, x = 2. Then, 123 → (1*2+2)*2+3=11 → 1*2+1=3. That is to say, Nobita should give the answer 3.

Sometimes a is too large, Nobita cannot work it out, can you help him?

Input

Input contains multiple cases, process to the end of file. Each case contains one line which contains only one number a (the length of a would not exceed 100000) as described above.

Output

For each case, you need to output the number when x = 1, 2 ... 9. You should output the nine numbers in one line separated by a single space.

Sample Input

123

Sample Output

6 3 4 9 8 7 9 9 9

Author: QU, Zhe
Contest: ZOJ Monthly, December 2010
Submit    Status