#include<iostream>
using namespace std;
string s,str;
int op,a,b,q;
int main()
{
cin>>q>>s;
while(q--)
{
cin>>op;
if(op==1)
{
cin>>str;
s+=str;
cout<<s<<endl;
}
else if(op==2)
{
cin>>a>>b;
s=s.substr(a,b);
cout<<s<<endl;
}
else if(op==3)
{
cin>>a>>str;
s.insert(a,str);
cout<<s<<endl;
}
else
{
cin>>str;
if(s.find(str)!=-1)
cout<<s.find(str)<<endl;
else cout<<"-1"<<endl;
}
}
return 0;
}
这段代码换成getline读入字符串就会出现错误