Welcome to ZOJ Problem Sets Information Select Problem Runs Ranklist ZOJ Problem Set - 2077
Equation Game

Time Limit: 2 Seconds      Memory Limit: 65536 KB

When we were young, almost everyone liked playing such a game:

Give you an equation, but there is no digit, but capital letters instead. Every letter stands for a different digit. Your task is to find what is each letter mean?

It's Cx's favourite game! Angel wants to help her to solve every equation to make her happy~~

We assume that there will be at most 10 letters in the equation. And "+", "*", "=", "(", and ")" will appear in the equation. Every result will not exceed 10^9.

Input

One line per testcase stands for the equation with letters. Length of the equation will not exceed 100.

Proceed to the end of file.

Output

One line per testcase, format as showed in sample output.

If there are more than one solutions, print the "smaller" one in lexical order (for example, "A=0 B=1" < "A=1 B=0", and we assume that if one number is "ABC", and A=0 is illegal).

If there is no solution, print one line contains "Poor Angel".

Sample Input

DCBA*ABCD=ECCBAAD+(A+A-B)
A=A
A=B

Sample Output

4321*1234=332114+(1+1-2)
1=1
Poor Angel

Author: JIANG, Yanyan
Source: JIANG, Yanyan's Contest #1
Submit    Status