Check Digits

No attempts yetTime limit1sMemory limit128 MB

Problem

Books, groceries, bank accounts, and credit cards are all identified mainly by a number, and those numbers often run to many digits. Transcribing one is easy to get wrong, so most numbering schemes carry a mechanism that detects errors and sometimes corrects them.

The simplest scheme appends a single check digit. Multiply the rightmost digit by 22, the digit to its left by 33, and so on, raising the weight by 11 at every step to the left, then add all the products. Divide that sum by 1111 and subtract the remainder from 1111. If the result lies between 11 and 99, append it to the right end of the number. If the result is 1111, append the digit 00 as the check digit. If the result is 1010, reject the original number.

To test whether a complete number is correct, multiply successive digits from the right by 11, 22, 33, ... and add the products. The number is good when that sum is divisible by 1111, and bad otherwise.

Take the number 27632763. Multiply 33 by 22 to get 66; multiply 66 by 33 to get 1818 and add for 2424; multiply 77 by 44 to get 2828 and add for 5252; multiply 22 by 55 to get 1010 and add for 6262. Dividing 6262 by 1111 leaves a remainder of 77, and 1111 minus 77 gives the check digit 44, so the full number is 2763427634. Check for yourself that the test works in the other direction, and that changing any digit, or even swapping two digits, makes the number bad.

Write a program that reads a series of numbers, each at most 1515 digits long, and produces the check digit for each one.

Input

The input is a series of numbers, one per line. Each number consists of decimal digits only with no embedded whitespace, and is at least 11 and at most 1515 digits long. The input ends with a line containing a single #.

Output

Print one line for every number in the input, excluding the terminating #. Each line holds the original number, then the four characters ->, then either the check digit or the word Rejected.