Arithmetic with Morse

No attempts yetTime limit1sMemory limit128 MB

Problem

Morse code is a way to send text messages as a series of dots "." and dashes "-". The letter "A" is written ".-" and the letter "B" is written "-...". The army and civil services have used this code for years. Here you will use it to do arithmetic.

We assign a value to dots and dashes, and we add two more characters to save space. The four allowed characters and their values are listed below.

CharacterValueNote
.1
-5
:2two dots
=10two dashes

A Morse number is a string made only of those four characters, and its value is the sum of the values of its characters. The value of "=.-.." is 10+1+5+1+1=1810 + 1 + 5 + 1 + 1 = 18. Each Morse number has exactly one value, but one value can be written as several Morse numbers. Three Morse numbers have value 33: "...", ".:" and ":.".

Numbers alone are not enough, so we add two operators. "+" is addition and "*" is multiplication. A Morse expression is a sequence of strings that alternates Morse numbers and operators, starts and ends with a Morse number, and contains at least one operator. To evaluate it, replace every Morse number by its value and evaluate the resulting arithmetic expression with the usual operator precedence and associativity, so multiplication is applied before addition. The Morse expression "=.-.. + ... * :." is worth 18+3×3=18+(3×3)=2718 + 3 \times 3 = 18 + (3 \times 3) = 27.

Given a Morse expression, print its value.

Input

The first line contains an integer NN (1N41 \le N \le 4), the number of operators in the Morse expression.

The second line contains the 2N+12N + 1 non-empty strings of the Morse expression, separated by spaces. Morse numbers and operators alternate, and the first and last strings are Morse numbers. Each Morse number is at most 77 characters long, and each of its characters is ".", "-", ":" or "=". Each operator is "+" or "*".

Output

Print one line with an integer, the value of the Morse expression.