#C2089. String Transformation Instructions

    ID: 45366 Type: Default 1000ms 256MiB

String Transformation Instructions

String Transformation Instructions

You are given an initial string s and a list of string transformation instructions. Each instruction can be one of the following:

  • Replace i c: Replace the character at index \(i\) (0-indexed) of s with the character \(c\).
  • Delete i: Delete the character at index \(i\) of s.
  • Append c: Append the character \(c\) at the end of s.

There may be multiple datasets in the input. Each dataset consists of an initial string, followed by an integer \(n\) denoting the number of instructions, followed by \(n\) lines describing the instructions to be applied sequentially to the string.

Your task is to process each dataset and output the final string after applying all the instructions.

inputFormat

The input is read from standard input (stdin) and consists of one or more datasets separated by a blank line. Each dataset is formatted as follows:

S
n
instruction_1
instruction_2
...
instruction_n

Here, S is the initial string, n is the number of instructions, and each instruction is a command in one of the formats described above. Indexes are 0-indexed.

outputFormat

For each dataset, output the modified string after processing all instructions, each on a separate line to standard output (stdout).

## sample
abcde
3
Replace 1 z
Delete 4
Append f
azcdf