#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    int n,q,l,r;
    cin>>n>>q;
    cin>>s;

    while(q--){
        cin>>l>>r;
        for(int i=r-1;i>=l-1;i--){
            string c = "";
            c.push_back(s[i]);
            s.insert(i,c);
        }
    }
    cout<<s<<"\n";
}
// 64 位输出请用 printf("%lld")

原来还有这种函数

s.insert(i,1,s[i]);