#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
int main()
{
int n;//操作次数
cin>>n;
string str;
cin>>str;
int num;
int i,j;
while(n--)
{
cin>>num;
if(1==num)
{
string line;//输入的操作字符串
cin>>line;
str+=line;
cout<<str<<endl;
}
if(2==num)
{
int a,b;
cin>>a>>b;
string str1=str;
str=" ";//非常关键,必须放空
str[0]=str1[a];
for(j=a,i=0;i<b;i++,j++)//i:新字符串数组 j:原字符串数组
{
str+=str1[j+1];
}
cout<<str<<endl;
}
if(3==num)
{
int c;
string line1,line2,line3;
cin>>c>>line2;
for(i=0;i<c;i++)
{
line1+=str[i];
}
for(i=c;i<str.size();i++)
{
line3+=str[i];
}
str=" ";
str=line1+line2;
str+=line3;
cout<<str<<endl;
}
if(4==num)
{
int position;
string line4;
cin>>line4;
position=str.find(line4);
cout<<position<<endl;
}
}
system("pause");
return 0;
}