#K59367. String Operations

    ID: 30849 Type: Default 1000ms 256MiB

String Operations

String Operations

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

  • 1 s: Append the string s to the current string. Print APPENDED as the result of this operation.
  • 2 x: Remove the last x characters from the current string. Print REMOVED as the result of this operation.
  • 3 s: Check if the substring s exists in the current string. Print YES if it does and NO otherwise.

Your task is to process these operations in the given order and output the corresponding result for each operation on a separate line.

Note: All operations are performed sequentially on the same string.

inputFormat

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

m
op1 arg
op2 arg
...
opm arg

Where m (an integer) is the number of operations. Each of the following m lines describes an operation. For an operation, the first number is the operation type (1, 2, or 3). For operation type 1 and 3, an additional string argument is provided. For operation type 2, an integer is provided representing the number of characters to remove.

outputFormat

For each operation, print the corresponding result on a separate line to standard output (stdout):

  • Operation 1: Print APPENDED
  • Operation 2: Print REMOVED
  • Operation 3: Print YES if the substring is found, or NO otherwise
## sample
6
1 abc
1 def
3 cd
2 3
3 def
3 ab
APPENDED

APPENDED YES REMOVED NO YES

</p>