#include <bits/stdc++.h>
#include<string.h>
using namespace std;
int main(){
//1.输入一个整数和最开始的字符串
int q;string str;
cin>>q;
cin>>str;//输入字符串
int a;string temp;//临时字符串
for(int i=0;i<q;i++){
//判断a是否为哪一个选项
cin>>a;
if(a==1){
cin>>temp;
str=str+temp;
cout<<str<<endl;
}
if(a==2){
int number1,number2;
cin>>number1>>number2;
str=str.substr(number1,number2);
cout<<str<<endl;
}
if(a==3){
int number3;
cin>>number3;
string d;
cin>>d;
str=str.insert(number3,d);//在字符串的确认位置下插入新的字符串
cout<<str<<endl;
}
if(a==4){
string e;
cin>>e;
int x=str.find(e);//查找字符串a的位置
if(x==string::npos){
cout<<-1<<endl;
}
else
cout<<x<<endl;
}
}
return 0;
}
知识点:1.字符串拼接可以直接进行加法运算
2.substr(pos1,pos2)可以截取从位置1到位置2的字符串
3.insert(pos,str)可以从指定位置插入新的字符串
4.find(s)可以在源字符串中找出是否包含s字符串中的首次出现的位置,并进行返回,如果不存在,即返回string::npos