The users' feedback for your most beloved open-source operating system has been gathered, and guess what the most requested feature turned out to be? Yes, it is finally what we all have been waiting for so long: extending the built-in calculator functionality!
One of the suggested extensions is adding the capability of evaluating polynomials, and that is what you are invited to participate in!
In this problem, you are given a polynomial entered by the user in the calculator, and are asked to evaluate it at a certain value.
The first line of input contains (0 < T \le 100), the number of polynomials. Each test case consists of two lines. The first line contains an integer (-1000 \le X \le 1000), the value for the variable at which the polynomial should be evaluated.
The second line contains a polynomial with integer coefficients. is a sum of terms of the form CX^E, where the coefficient and the exponent satisfy the following conditions:
is an integer satisfying 0 \le E \le 30. If E = 0, then CX^E is expressed as . If E = 1, then CX^E is expressed as , unless is or , in which cases CX^E is expressed as or .
is an integer. If is or and is not or , then CX^E appears as X^E or -X^E.
Only non-negative values that are not part of the first term in the polynomial are preceded by a sign.
Exponents in consecutive terms strictly decrease.
fits in a -bit signed integer.
For each test case, print the value of the polynomial evaluation. The result will fit in a -bit signed integer. Follow the output format below.
Example 1