#include <iostream>
#include <string>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, t;
    string s;
    cin >> n >> t >> s;

    while (t--) {
        int l, r;
        cin >> l >> r;
        for (int i = r - 1; i >= l - 1; i--) {
            s.insert(i + 1, 1, s[i]);
        }
    }

    cout << s << '\n';
    return 0;
}