1962. Hide That Number

单点时限: 2.0 sec

内存限制: 256 MB

According to Wikipedia, Cryptography is “the practice and study of hiding information” and this is exactly what Alex is looking for. Ever since he was a kid, Alex was paranoid over someone laying their hands on his phone book. He decided that he must write the numbers in some secret way that only he can decipher. At first he tried quite complex algorithms, but that slowed him down when he needed to dial a number fast. He finally came up with the following algorithm: Rather than writing down the number itself, Alex would shift the number one place to the left (as if multiplying it by 10,) then adding the shifted number to the original. For example, if the phone number was 123, Alex would add 1230 to it, resulting in 1353. To make what he writes looks as a regular phone number, Alex truncates the result (from the left,) so that it has as many digits as the original phone number. In this example, Alex writes 353 instead of 123 in his phone book.

Alex needs a program to print the original phone number given what is written in his phone book. Alex, who by the way is a good friend of Johnny, isn’t that good in arithmetic. It is quite possible that the numbers are messed up. The program should print “IMPOSSIBLE” (without the quotes) if the original number cannot be computed.

输入格式

Your program will be tested on one or more test cases. Each case is specified on a separate line and is made of a single positive number having less than 1,000,000 digits.

The last line of the input file is made of a single zero.

输出格式

For each test case, output the result on a single line using the following format:

k. result

Where k is the test case number (starting at 1).

样例

Input
353
9988
123456
0
Output
1. 123
2. IMPOSSIBLE
3. 738496

19 人解决,31 人已尝试。

25 份提交通过,共有 144 份提交。

5.8 EMB 奖励。

创建: 16 年前.

修改: 6 年,7 月前.

最后提交: 10 月,2 周前.

来源: Arab and North Africa 2007

题目标签