#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
	string s;
    cin >> s;
    int n;
    cin>>n;
    while(n--){
    	string cmd;
    	cin>>cmd;
    	int type = cmd[0] - '0';
    	int i = cmd[1] - '0';
    	int len = cmd[2] - '0';
    	if(type == 0){
    		reverse(s.begin()+i,s.begin()+i+len);
    		cout<<s<<endl;
		}else if(type == 1){
			s.replace(i,len,cmd.substr(3));
			cout<<s<<endl;
		}
	}     
}