#C8932. Simple Text Editor

    ID: 52969 Type: Default 1000ms 256MiB

Simple Text Editor

Simple Text Editor

You are required to implement a simple text editor. Initially, the editor contains an empty string \(S\). You will be given a series of operations. There are two types:

  • Append Operation (1 W): Append the string \(W\) to the end of \(S\).
  • Delete Operation (2 k): Delete the last \(k\) characters from \(S\). In other words, update \(S\) to \(S[0:|S|-k]\), where \(|S|\) is the current length of \(S\).

After performing all operations in the given order, output the final state of the string \(S\).

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains an integer \(N\), representing the number of operations.
  • Each of the next \(N\) lines contains an operation in one of the following formats:
    • 1 W: Append the string \(W\) to \(S\).
    • 2 k: Delete the last \(k\) characters from \(S\).

outputFormat

Output a single line to standard output (stdout) containing the final state of the string \(S\) after performing all the operations.

## sample
2
1 abc
1 def
abcdef