H. Evaluation
time limit per test
3 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

We define an expression as a string that satisfies the following conditions.

  • Each character is either a decimal digit, +, -, or *.
  • There are no two consecutive indices that both contain a non-digit character.
  • The first character is a decimal digit.
  • The last character is a decimal digit.

There is a string $$$S$$$ of length $$$n$$$, which is an expression. It is guaranteed that $$$S$$$ does not contain a zero in its content.

For any positive integer $$$k$$$, we define $$$S \times k$$$ as $$$\overbrace{S+S+S+\ldots+S+S+S}^{k\text{ times}}$$$, where $$$+$$$ denotes string concatenation. Then, for any $$$k$$$, $$$S \times k$$$ is also an expression.

Additionally, for any string $$$T$$$ that is an expression, we define $$$\mathtt{eval}(T)$$$ as the result of evaluating the string as a mathematical expression modulo $$$998\,244\,353$$$. For clarity, +, -, and * correspond to addition, subtraction, and multiplication. Also, operator precedence applies, so * is evaluated before + or -.

Given $$$q$$$ positive integers $$$k_1,k_2,\ldots,k_q$$$, please evaluate the value of $$$\mathtt{eval}(S \times k_i)$$$ for each of them.

Input

The first line contains an integer $$$n$$$ — the length of $$$S$$$ ($$$1 \le n \le 500$$$).

The second line contains the string $$$S$$$ of length $$$n$$$.

The third line contains an integer $$$q$$$ — the number of queries ($$$1 \le q \le 100\,000$$$).

The fourth line contains $$$q$$$ integers $$$k_1,k_2,\ldots,k_q$$$, denoting the queries ($$$1 \le k_i \le 10^9$$$).

It is guaranteed that $$$S$$$ is an expression that does not contain a '0'.

Output

For each query, output the answer to the query on a separate line.

Example
Input
9
1*2-3*4+5
3
1 2 727
Output
998244348
85
65335
Note

When $$$k=1$$$, the expression "1*2-3*4+5" evaluates to $$$-5 \equiv 998\,244\,348 \bmod{998\,244\,353}$$$.

When $$$k=2$$$, the expression "1*2-3*4+51*2-3*4+5" evaluates to $$$85 \equiv 85 \bmod{998\,244\,353}$$$.

When $$$k=727$$$, the expression "1*2-3*4+51*2-3*4+5...1*2-3*4+5" evaluates to $$$65\,335 \equiv 65\,335 \bmod{998\,244\,353}$$$.