1807 Execute HVM


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 32M

Problem types
Allowed languages
C, C++, Java, Python

Description

HVM is short for Hack Virtual Machine. It's a tiny script. Maybe most of you know it. If you don't know, you can go http://www.hacker.org/hvm for more information. This problem sounds very simple, just to write a simple HVM executor. The original HVM is not written by C or C++, so it's a little different. If abs (a) > abs (b) (a, b != 0) and a * b

Input

This problem has several cases, input until EOF. The first line of each case has one integer N (0 <= N <= 16384), indicates the number of initialized memory buffer. If N is not 0, it follows a line has N integer(s). The ith number indicates MemoryBuffer[i]. Next line contains a string (no longer then 2048), indicates the HVM Command. You can consider that all of the data is valid.

Output

For each case, you should output the trace box and the result that the command will print. Each step of the command except empty command (' ') would have a trace. The format is: Command [Stack element y, Stack element y – 1, ... Stack top] Notice that there's a blank space after ','.

Sample

Input

0
123ppp

Output

1 [1]
2 [1, 2]
3 [1, 2, 3]
p [1, 2]
p [1]
p []
321

Hint

Hacker.org/challenge is fun~


Source: XadillaX


Comments

There are no comments at the moment.