#include <bits/stdc++.h>
using namespace std;

int main()
{
	string s;
	int n;
	while(cin>>s)
	{
		cin>>n;
		while(n--)
		{
			string s1;
			cin>>s1;
			if(s1[0]=='0')
			{
				reverse(s.begin()+(s1[1]-'0'),s.begin()+(s1[1]-'0')+(s1[2]-'0'));	
			}
			else if(s1[0]=='1')
			{
				s.replace(s1[1]-'0',s1[2]-'0',s1.substr(3));
			}
			cout<<s<<endl; 
		}
	}
	return 0;
}