A simplified text editor holds a single line of text, starting empty. It supports m operations, each one of:
TYPE s— append the tokens(non-empty, lowercase letters and digits only, no spaces) to the end of the current text.DELETE k— remove the lastkcharacters of the current text (it is guaranteed thatkdoes not exceed the current text's length).UNDO— revert the text to the state it was in immediately before the most recentTYPE/DELETEoperation that has not already been undone. If there is nothing left to undo, this operation does nothing.REDO— reapply the most recently undone operation. If there is nothing to redo (either nothing has been undone, or a newTYPE/DELETEwas performed since the last undo, which discards the redo history), this operation does nothing.
Process all m operations in order and report the final text.
Input format
Line 1: an integer m.
Next m lines: one operation each, in the form described above.
Output format
A single line: the final text (an empty line if the final text is empty).
Constraints
- 1 ≤ m ≤ 1000
- For
TYPE s: 1 ≤ length ofs≤ 20, lowercase English letters and digits only. - For
DELETE k: 1 ≤ k ≤ current text length. - The final text length never exceeds 20000 characters.