Kvantocryptarithm#11844

Kvantocryptarithm

4 seconds
256 megabytes
Hard

Recently, Kvanta became fascinated by cryptarithms. During her practice she came across a task she cannot solve, so Kvanta asks you for help.

You are given three strings s_1, s_2, s_3 (the length of each does not exceed  characters). Every character of a string is either an uppercase Latin letter A...Z, or a decimal digit 0...9.

It is required to assign a unique decimal digit to every distinct letter in such a way that the following conditions hold:

You must find at least one triple of numbers that satisfies all the conditions, or tell Kvanta that she has been wasting her time and such a triple does not exist.

Input

The input consists of three lines.

In the -th line a string s_i is given (1 \le |s_i| \le 18). Every character of s_i is either an uppercase Latin letter or a decimal digit.

Output

If a solution exists, output three numbers—the values of s_1, s_2 and s_3 after replacing all letters by the corresponding digits. Print the numbers in the same order, one per line.

If there is no valid assignment, output .

If there are several solutions, you are allowed to print any of them.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Note

  • In the first example, after substituting A = 3, B = 1, C = 4, we get 93 + 31 = 124, which satisfies the cryptarithm.

  • In the second example, there is no way to assign distinct digits to the letters so that the sum of the first two numbers equals the third; therefore, the output is .