11441 - Postfix Evaluation   

Description

Evaluate the result of a given numerical expression written in postfix notation.

Input

The first line of input contains an integer N (N ≤ 100) which denotes the number of test cases. Each test case begins with an integer M (M ≤ 10000) representing the number of tokens in the expression, followed by M tokens in the next line. Tokens are separated by spaces, and there are two types of tokens: operators and operands.  Operators will only be “+”, “-”, “*” , or “/”; operands are integers in the range [0, 100]. The division operator “/” here is considered as integer division. You may assume that all of the expressions are valid (division-by-zero would never occur) and the evaluated results (in each stage of evaluation) will fit in 32-bit signed integer.

Output

For each test case, please output a line begins with the test case number “Case i:”, and then a space character followed by the evaluated answer.

Sample Input  Download

Sample Output  Download

Tags




Discuss