#K49207. Text Editor Operations Simulation
Text Editor Operations Simulation
Text Editor Operations Simulation
You are given a sequence of operations to perform on a text string. Initially, the text is empty. The operations are provided in the following formats:
- 1 c: Append character $c$ to the end of the text.
- 2: Delete the last character of the text, if the text is non-empty.
- 3: Undo the most recent operation (either insertion or deletion). Undoing an insertion will remove the last inserted character again, whereas undoing a deletion will restore the removed character.
Your task is to simulate these operations in the order given and output the final text.
inputFormat
The input begins with an integer $n$, the number of operations. The following $n$ lines each contain one operation in one of the following formats: "1 c", "2", or "3".
outputFormat
Output the final text after processing all $n$ operations.
## sample5
1 a
1 b
1 c
2
3
abc