P2790 ccj and zrz's Blocks Problem

Background

ccj and zrz were so bored that they started playing with building blocks... (This problem is from UVA 101, translation from "算法竞赛入门经典 2".)

Description

From left to right there are $n$ blocks, numbered from $0$ to $n-1$. Simulate the following 4 operations (here $a$ and $b$ are block numbers; “return to initial position” means, for example, block $1$ goes back to position $1$): - $\texttt{move }a\texttt{ onto }b$: Return all blocks above $a$ and above $b$ to their initial positions, then place $a$ on top of $b$. - $\texttt{move }a\texttt{ over }b$: Return all blocks above $a$ to their initial positions, then place $a$ on the top of the stack containing $b$. - $\texttt{pile }a\texttt{ onto }b$: Return all blocks above $b$ to their initial positions, then move $a$ together with all blocks above it as a whole onto $b$. - $\texttt{pile }a\texttt{ over }b$: Move $a$ together with all blocks above it as a whole onto the top of the stack containing $b$. - Stop when encountering $\texttt{quit}$. If $a$ and $b$ are in the same stack, the instruction is illegal and should be ignored. Finally, output the list of blocks at each position, in order from bottom to top.

Input Format

The first line contains an integer $n$. Then follow several lines, each containing one instruction (the syntax will be correct). Stop when encountering $\texttt{quit}$.

Output Format

Output exactly $n$ lines. On the $i$-th line, output $i$ followed by a colon, then a space, then all the blocks at position $i$, listed from bottom to top.

Explanation/Hint

### Constraints and Notes For all testdata, $0