This is the most direct problem ever, you are required to implement some basic string operations like insert and substring.
In this problem |S| means the length of the string S.
Note: We didn't find a good name for this problem.
The input starts with a line containing a string S (1 ≤ |S| ≤ 200,000), followed by one or more lines each describing one of the following operations to perform on S (all indices are zero based, and the quotes are for clarity):
Strings S and R will consist of lower case English letters only ('a' to 'z'), and |S| will never get greater than 200,000 as a result of the operations. Also, the total number of characters to be printed will not exceed 200,000.
For every "P X Y" operation in the input, print one line with the corresponding substring.
acm
I ac 3
P 0 3
I x 3
I xxxx 6
I pc 6
P 0 11
END
acma
acmxacpcxxxx