Encoded Sum
You are given a set of strings, each element of which represents a positive integer written using the letters 'A' through 'J' instead of digits. You know that each letter represents exactly one digit, and each digit is represented by exactly one letter. You also know that none of the integers start with zero. Find the maximum possible sum of the given integers.
Input
Consists of multiple test cases. The first line of each test case contains the number of strings n (1 ≤ n ≤ 50). Then goes n strings of length no more than 12 that contains only the letters 'A' through 'J'. There will be always at least one letter between 'A' and 'J', inclusive, that never occurs as the first character of any input string.
Output
For each test case print in a separate line the maximum possible sum of the given integers.