Encoded Sum#1594

Encoded Sum

1 second
128 megabytes
Very easy

You are given several strings, each of which represents a positive integer. However, instead of digits, the strings use the letters 'A' through 'J'. Each letter represents exactly one digit, and each digit is represented by exactly one letter. No number begins with zero.

Input

The input consists of multiple test cases. The first line of each test case contains the number of strings (1 \leq n \leq 50). The following lines each contain a string of at most letters, using only the letters 'A' through 'J'. There is always at least one letter from 'A' to 'J' that never occurs as the first character of any string in the input.

Output

For each test case, output on a separate line the largest possible sum of the given integers.

Examples

Example 1

Loading
Loading