You are given some sequence of commands; for each sequence output the final result as a string.
The commands are:
| Command | description |
| ADD x | Append x to current string, x=[a-z][A-Z] |
| SELECT a b | Select the string from position a to b. The first character in the string has position 1. |
| CANCEL | Unselect string |
| COPY | Copy current selected string to the clipboard; if nothing is selected, do nothing. |
| PASTE | Append the string on the clipboard to current string, if nothing is on the clipboard, do nothing |
| REVERSE | Reverse current string |
The initial string for each sequence is the empty string.
There may be several test cases. Each test case starts with a number n (1<=n<=100), denoting the length of the sequence. Following are n commands on n lines.
For each sequence, output the result string on a line by itself.
4 ADD M ADD C ADD A REVERSE 6 ADD A ADD C ADD M SELECT 1 2 COPY PASTE
ACM ACMAC
Migrated from old NTUJ.
| No. | Testdata Range | Score |
|---|