TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

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.

Input Format

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.

Output Format

For each sequence, output the result string on a line by itself.

Sample Input 1

4
ADD M
ADD C
ADD A
REVERSE
6
ADD A
ADD C
ADD M
SELECT 1 2
COPY
PASTE

Sample Output 1

ACM
ACMAC

Hints

Problem Source

Migrated from old NTUJ.

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 20