This is the most direct problem ever, you are required to implement some basic string operations like insert and substring.
In this problem means the length of the string .
Note: We didn't find a good name for this problem.
Your program will be tested on one or more test cases. The first line of the input will be a single integer , the number of test cases (1 \leq T \leq 100). Followed by the test cases, each test case starts with a line containing a string (1 \leq |S| \leq 1000000), followed by one or more lines each describing one of the following operations to perform on (all indices are zero based, and the quotes are for clarity):
"I R X" means insert the string (1 \leq |R| \leq 1000000) in at index (0 \leq X \leq |S|), when equals this means append at the end of . For example, the result of inserting xy in abc at position will be axybc, and the result of inserting xy in abc at position will be abcxy, and the result of inserting xy in abc at position will be xyabc.
"P X Y" means print the substring of from to , inclusive (0 \leq X \leq Y < |S|). For example the substring from to of abc is abc, and the string from to of abc is b.
"END" Indicates the end of operations for the test case.
Strings and will consist of lower case English letters only ('a' to 'z'), and will never get greater than as a result of the operations for any test case. Also, the total number of characters to be printed for any test case will not exceed .
Note: Make sure to use fast IO operations, because the input and output files are very large.
For every "P X Y" operation in the input, print one line with the corresponding substring.
Example 1