9200 - Postfix Evaluation   

Description

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

Input

The first line of the 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 the operators contain only “+”, “-”, “*” and “/”; the operands are integers in the range [0, 100]. The division operator “/” here is considered as integral division. You may assume that all of the expressions are valid (divide-by-zero would never occur) and the answer will fit in 32-bit signed integers. Evaluated results (in each stage of the evaluation ) will fit in 100-digit signed integers and divide-by-bignumber would never occur.

Output

The output of each test case occupies a line. Each 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