#K64732. Simple Text Editor

    ID: 32041 Type: Default 1000ms 256MiB

Simple Text Editor

Simple Text Editor

You are given an initially empty string \( S \). You need to perform a series of operations on \( S \) as described below:

  • APPEND W: Append the string \( W \) to the end of \( S \).
  • DELETE k: Delete the last \( k \) characters from \( S \).
  • PRINT p: Print the \( p \)-th character of \( S \) (using 1-indexing).

You will be given a list of operations. For each PRINT operation, output the corresponding character.

Note: It is guaranteed that all DELETE and PRINT operations are valid, meaning you will never be asked to delete more characters than present or print a character from an invalid position.

The following examples demonstrate the process:

Input:
4
APPEND abc
PRINT 1
APPEND def
PRINT 4

Output: a d

</p>

and

Input:
3
APPEND abcdef
DELETE 3
PRINT 1

Output: a

</p>

inputFormat

The first line contains an integer \( n \) representing the number of operations. The following \( n \) lines each contain an operation in one of the following formats:

  • APPEND W
  • DELETE k
  • PRINT p

Each operation is provided on a new line and all operations are valid.

outputFormat

For each PRINT operation, output the resulting character on a new line.

## sample
4
APPEND abc
PRINT 1
APPEND def
PRINT 4
a

d

</p>