#include <bits/stdc++.h>
const int N = 2e5 + 10;
const int inf = 0x3f3f3f3f;
using namespace std;
using ull = unsigned long long int;
using ll = long long int;
string f(string a){
string res;
for(int i=0;i<a.size();i++){
res+=a[i];
res+=a[i];
}
return res;
}
int main() {
// ios::sync_with_stdio(false);
// cin.tie(0);
int n,q;
cin>>n>>q;
string a;
cin>>a;
a='*'+a;
for(int i=1;i<=q;i++){
int L,R;
cin>>L>>R;
string per,ans,rep;
per=a.substr(0,L);
ans=a.substr(L,R-L+1);
rep=a.substr(R+1);
a=per+f(ans)+rep;
}
for(int i=1;i<a.size();i++){
cout<<a[i];
}
return 0;
}
用substr截一下中间的[L,R]然后改一下结回去就可以了

京公网安备 11010502036488号