Programmers use version control systems to manage files in their projects, but in these systems, versions are saved only when you manually submit. Can you implement an IDE that automatically saves a new version whenever you insert or delete a string?
Positions in the buffer are numbered from from left to right. Initially, the buffer is empty and in version . Then you can execute commands (where means the version before executing the command, and L_v means the length of buffer at version ):
: insert string after position (0 \leq p \leq L_{vnow}, p=0 means insert before the start of the buffer). contains at least and at most letters.
: remove characters starting at position (p \geq 1, p+c \leq L_{vnow}+1). The remaining characters (if any) will be shifted left, filling the blank.
: print characters starting at position (p \geq 1, p+c \leq L_v+1), in version (1 \leq v \leq vnow).
The first command is guaranteed to be command (insert). After executing each command or , version is incremented by .
There is only one test case. It begins with a single integer (1 \leq n \leq 50000), the number of commands.
Each of the following lines contains a command. The total length of all inserted string will not exceed .
Print the results of command , in order. The total length of all printed strings will not exceed .
Obfuscation
In order to prevent you from preprocessing the command, we adopt the following obfuscation scheme:
Each type- command becomes p+d
Each type- command becomes p+d c+d
Each type- command becomes v+d p+d c+d
Where is the number of lowercase letter 'c' you printed, before processing this command.
For example, the unobfuscated sample input is:
6
1 0 abcdefgh
2 4 3
3 1 2 5
3 2 2 3
1 2 xy
3 3 2 4After the obfuscation, the sample input would be:
6
1 0 abcdefgh
2 4 3
3 1 2 5
3 3 3 4
1 4 xy
3 5 4 6This is the real input that your program will read.
Example 1