#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
void reverse(string &s, int left, int length){
    int right = left + length - 1;
    for(int i = left,j = right;i < (left+right+1)/2;++i,--j){
        char temp = s[i];
        s[i] = s[j];
        s[j] = temp;
    }
}
void second(string &s, int left, int length, string change){
    string part1 = s.substr(0,left);
    string part2 = s.substr(left+length);
    s = part1 + change + part2;
}
int main(){
    string s;int n;
    cin >> s >> n ;
    while(n--){
        string temp;
        cin >> temp;
        if(temp[0]-'0' == 0)
            reverse(s, temp[1]-'0', temp[2]-'0');
        else
            second(s, temp[1]-'0', temp[2]-'0', temp.substr(3));
        cout << s <<endl;
    }
    return 0;
}