#P7226. Reconstructing the Original Exponential Sum

    ID: 20430 Type: Default 1000ms 256MiB

Reconstructing the Original Exponential Sum

Reconstructing the Original Exponential Sum

A teacher sent an email with a task for the students:

Originally, you were supposed to compute the value of

\[ X = num_1^{p_1} + num_2^{p_2} + \cdots + num_n^{p_n} \]

where each numi is an integer and each exponent pi is a single digit.

However, due to an unexpected error, the calculation was altered to the form

\[ X = q_1 + q_2 + \cdots + q_n \]

with the definition

\[ q_i = num_i \times 10 + p_i \]

For example, if the original input intended was 212 + 1253, the erroneous version becomes 212 + 1253. Your task is to help the teacher by reconstructing the correct value of X (i.e. computing num1p1 + num2p2 + ... + numnpn) based on the given erroneous numbers.

inputFormat

The first line contains a single integer n representing the number of values.

The following n lines each contain a single integer qi which is formed as follows:

\[ q_i = num_i \times 10 + p_i \]

where numi is the base and pi is the exponent (a single digit).

outputFormat

Output a single integer representing the original value of X, calculated as:

\[ X = num_1^{p_1} + num_2^{p_2} + \cdots + num_n^{p_n} \]

sample

2
212
1253
1953566