Write a program which performs a sequence of commands to a given string $str$. The command is one of:
Note that the indices of $str$ start with 0.
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
For each print command, print a string in a line.
abcde 3 replace 1 3 xyz reverse 0 2 print 1 4
xaze
xyz 3 print 0 2 replace 0 2 abc print 0 2
xyz abc