Scrabble is a word game in which two to four players score points by placing tiles — each bearing a single letter — onto a game board. The tiles must form words which, in crossword fashion, flow left to right in rows or downwards in columns. The words must be defined in a standard dictionary, or be present in specified reference works that provide a list of officially permissible words.

Each letter of the alphabet is assigned a fixed score. The score of a word that is placed on the Scrabble board is simply the sum of the scores of the individual letters of the word.

scrabble
Scores of the individual letters in the English version of Scrabble.

For example, if we replace each letter of the word spectromicroscope by its corresponding score, we obtain the digit sequence 13131113131113131. Note that the exact same digit sequence is obtained if the sequence is read from right to left. That's why the word spectromicroscope is called a palindrome in Scrabble.

spectromicroscope
The word spectromicroscope is a palindrome in Scrabble.

If we add the scores of the individual letters of the word spectromicroscope, we see that the word yields 29 points on the Scrabble board.

When placing a word on the Scrabble board it may happen that the score of an individual letter must be multiplied by a factor $$n \in \{2, 3\}$$. For longer words it is even possible that the score of more than one letter has to be multiplied, whereby the multiplication factors do not necessarily have to be same. This is indicated in Scrabble notation by preceding the letters whose score must be multiplied by the multiplication factor. As such, the Scrabble notation e2qu3in2ox indicates that the score of the letters q and o must be doubled and that the score of the letter i must be tripled. In this case the word equinox yields a total score of 36 points.

Assignment

Scrabble words only contain letters and no distinction is made between uppercase and lowercase letters. Each letter of the alphabet is assigned a fixed score:

score letters
1 A, E, I, L, N, O, R, S, T, U
2 D, G
3 B, C, M, P
4 F, H, V, W, Y
5 K
8 J, X
10 Q, Z

Your task:

Example

>>> digits('spectromicroscope')
'13131113131113131'
>>> digits('eQuInOx')
'1X11118'
>>> digits('OVEREFFUSIVE')
'141114411141'

>>> ispalindrome('spectromicroscope')
True
>>> ispalindrome('eQuInOx')
False
>>> ispalindrome('OVEREFFUSIVE')
True

>>> score('spectromicroscope')
29
>>> score('e2Qu3In2Ox')
36
>>> score('O3VERE2F3FUSI2VE')
48