Read a set of strings (to be operated), read an int n record, and record several commands. There are two commands in total: 1. Flip the strings from the character with the subscript i to the reverse order of i+len-1; 2. If the first bit is 1, replace the originally read string subscript i to i+len-1 with the string starting from the fourth bit of the command to the last. Each time a command is executed, the new string replaces the old string (that is, the next command acts on the new string obtained). Command format: the first digit 0 represents flip, and 1 represents replace; The second bit represents the starting subscript int i of the string to be operated; The third bit indicates the length of the string to be operated, int len.
Input description:
 Input has multiple sets of data. Each group input a string (no more than 100), then input n, and then input n instructions (the instructions must be valid).


Output description:
 Output the result after the string operation according to the instruction.
Example 1

input

 bac two 003 112as

output

 cab cas
Loading