## NOI '00 P6 - Symbol Deciphering

View as PDF

Points: 40 (partial)
Time limit: 1.0s
Memory limit: 16M

Problem type
##### National Olympiad in Informatics, China, 2000

Archeologists have discovered that the several thousand-year-old mathematics of the ancient Mei civilization was extremely advanced. They understood methods of addition and multiplication for multi-digit numbers. Their rules for representing expressions and performing calculations are exactly the same as those used in the modern day (addition of integers are in base-10, the leftmost digit is the most-significant, the highest digit cannot be zero; expressions are infix, multiplication comes before addition, etc.), with the only exception being that mathematical symbols themselves are written differently. There is sufficient evidence to show that ancient Mei mathematics uses a total of operators which have a one-to-one correspondence to the modern day symbols , and . To simplify the representations of the symbols, we shall use the first alphabetical letters in place of these symbols (known as the ancient Mei mathematical symbols). The problem is, no one currently knows the general relationship for matching the ancient Mei mathematical symbols to modern mathematical symbols.

On a stone wall, archaeologists have discovered a set of equations expressed using the ancient Mei symbols. They have concluded that each row contains only one equal sign, the left and right sides of each equal sign contain mathematical expressions (containing only numbers and operators), and that expressions on the two sides of equal signs are equivalent.

Assuming that this set of equations is successful, please write a program that deciphers the relationship between ancient Mei mathematical symbols and modern mathematical symbols.

#### Input Specification

The first line of input contains an integer  . Each of the following lines will contain an equation. Each equation will consist of as few as characters and as many as characters.

#### Output Specification

If there does not exist a possible relationship that satisfies the set of equations, output noway on a single line.
If there exist a possible mapping that satisfies the set of equations, output all the mappings between ancient Mei symbols and modern symbols that are known for certain. Each line should contain two characters, where the first character is an ancient Mei mathematical symbol and the second character is the modern mathematical symbol to which it is mapped. Output the mappings in alphabetical order.

#### Sample Input

2
abcdec
cdefe

#### Sample Output

a6
b*
d=
f+

#### Explanation

In the sample above, the possibilities for the equations in modern symbols are , , and . It can be seen that the confirmed relationships only consist of a mapping of to 6, to , to , and to , which should be outputted. Although possible mappings for can be successfully found, there is no unique relationship for them, and thus they should not be outputted. The other ancient Mei mathematical symbols are completely unverifiable, and also should not be outputted.

Problem translated to English by Alex.

## Comments

There are no comments at the moment.