考点:字符串操作
#include<bits/stdc++.h>
using namespace std;
const int MAXSIZE=1001;
int main() {
string str;
while(cin>>str) {
int n;
cin>>n;
string cmd;
for(int i=0; i<n; i++) {
cin>>cmd;
int p=cmd[1]-'0';
int len=cmd[2]-'0';
if(cmd[0]=='0') {
char cs[100];
strcpy(cs,str.c_str());
reverse(cs+p,cs+p+len);
str=cs;
} else {
string tmp=cmd.substr(3);
str.replace(p,len,tmp);
}
cout<<str<<endl;
}
}
return 0;
}