The so-called "insect-eating calculation" means that part of the original calculation formula was eaten by insects, and we need to compute the missing letters based on the remaining numbers. Let's look at a simple example:
The character #
represents the number was eaten by the insects. According to the formula, we can easily conclude: the two numbers in the first summand are
Now, we make two constraints on the problem:
First, we only consider the insect-eating calculation of addition. The addition here is addition in base
Secondly, the insects have eaten up all the numbers. We only know which numbers are the same. We represent the same numbers with the same letters and different numbers with different letters. If the formula is in base A
corresponds to B
corresponds to
The above formula is a formula in base
Input Specification
The first line of the input contains a positive integer
Output Specification
Output a line denoting the correspondence between the letters and digits: you should output
Sample Input
5
ABCED
BDACE
EBBAA
Sample Output
1 0 3 4 2
Constraints
- For
of test cases, . - For
of test cases, . - For all test cases,
.
Comments