The user feedback for your favourite open-source operating system is in, and the most requested feature turned out to be an extension of the built-in calculator. One of the suggested extensions is evaluating polynomials, and that is the part you are building.
You are given a polynomial that the user typed into the calculator together with a value for the variable. Evaluate the polynomial at that value.
The first line contains T, the number of polynomials. (0<T≤100)
Each test case consists of two lines. The first line contains an integer X, the value of the variable the polynomial is evaluated at. (−1000≤X≤1000)
The second line contains a polynomial P whose coefficients are all integers. P is a sum of terms of the form CXE, where the coefficient C and the exponent E satisfy the following conditions.
A polynomial line contains no spaces.
For each test case, print the value of the polynomial on its own line. If the value for test case i is V, print it as Case #i: V. Test cases are numbered from 1. The result fits in a 32-bit signed integer.