We define an expression as a string that satisfies the following conditions.
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.
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'.
For each query, output the answer to the query on a separate line.
91*2-3*4+531 2 727
998244348 85 65335
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}$$$.