#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,y;
cin>>n;
string a,str;
cin>>a;
for(i=1;i<=n;i++)
{
cin>>y;
if(y==1)
{
cin>>str;
a+=str;
cout<<a<<endl;
}
if(y==2)
{
int u,ui;
cin>>u>>ui;
a=a.substr(u,ui);
cout<<a<<endl;
}
if(y==3)
{
int r;
cin>>r>>str;
a.insert(r-1,str);
cout<<a<<endl;
}
if(y==4)
{
int o;
cin>>str;
o=a.find(str);
if(o==string::npos)
{
cout<<-1<<endl;
}
else
cout<<o+1<<endl;
}
}
}
3个WA+2个RE,大佬求解