Gochangyoung modified the stack a little and built the GoStack. A GoStack can only store integers and supports the following 10 operations.
For convenience, the number on the top of the stack is called the first number, the one below it the second number, then the third, and so on.
For binary operations, the first number is the right operand and the second number is the left operand. When an operation runs, both numbers are popped from the stack and the result is pushed back.
Any of the following situations is a program error:
To remove the ambiguity of dividing negative numbers, the following rule is used. If an operand is negative, take its absolute value before computing. Then decide the signs of the quotient and remainder as follows.
For example, $13 \div (-4) = -3$, $(-13) \bmod 4 = -1$, and $(-13) \bmod (-4) = -1$.
When a program error occurs, execution stops immediately and no further command is carried out.
The input consists of the descriptions of several machines. Each machine description is split into a program and an input area.
The program is made of commands, one per line. Each command is one of the three-letter uppercase words described above, and no other characters appear. NUM is followed by a single integer separated by a space, and this integer is between $0$ and $10^9$ inclusive. The program ends at the END line.
The first line of the input area contains the number of executions $N$. ($0 \le N \le 10{,}000$) Each of the next $N$ lines contains one input value $V_i$. ($0 \le V_i \le 10^9$) The program is run once for each input value, and every run is independent. At the start of each run the stack contains only that input value $V_i$.
Machine descriptions are separated by a blank line. A QUIT line means there are no more machine descriptions. No single program has more than $100{,}000$ commands, and the stack never holds $1{,}000$ or more numbers during a run.
For each input value, run the program and print its output value on its own line. The output value is the number left on the stack when the run finishes.
If a program error occurred, or the stack does not hold exactly one number when the run finishes, print ERROR instead.
Separate the outputs of different machines with a single blank line. Do not add a blank line after the last machine's output.