#C7746. String Manipulation Sequence

    ID: 51651 Type: Default 1000ms 256MiB

String Manipulation Sequence

String Manipulation Sequence

You are given a sequence of operations that modify a string. Initially, the string is empty. There are three types of operations:

  • Append S: Append the string S to the end of the current string.
  • Remove k: Remove the last k characters from the current string.
  • Print k: Print the k^\text{th} character of the current string (1-indexed).

The operations are performed sequentially. Your program should read a number of operations from standard input, execute them, and whenever a Print operation is encountered, print the corresponding character to standard output.

Note: All indices in the operations are 1-indexed. For example, the operation Print 2 prints the second character of the current string.

inputFormat

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:

  • Append S
  • Remove k
  • Print k

Each operation is separated by a newline. Input is read from standard input.

outputFormat

Whenever a Print operation is encountered, output the corresponding character on a new line. The result of each print operation should appear in the order they are executed. Output is written to standard output.

## sample
5
Append abc
Print 2
Append xy
Remove 3
Print 2
b

b

</p>