#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define inf 1e18
const int mod=1e9+7;
const int N=2e5+5;
void solve(){
string s;
cin>>s;
int n;
cin>>n;
while(n--){
int x,y;
string a,b,t;
cin>>x>>y>>a>>b;
t=s.substr(x-1,y-x+1);
s.erase(x-1,y-x+1);
int f=s.find(a+b);
int u=s.find(a);
if(f==-1) s+=t;
else{
s.insert(f+a.size(),t);
}
// cout<<s<<endl;
}
cout<<s;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int tt=1;
// cin>>tt;
while(tt--) solve();
return 0;
}
03-20
308
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)