#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>PII;
const int N = 2e5 + 10;
const int MOD = 998244353;
const int INF = 0X3F3F3F3F;
const int dx[] = {-1, 1, 0, 0, -1, -1, +1, +1};
const int dy[] = {0, 0, -1, 1, -1, +1, -1, +1};
const int M = 1e6 + 10;
int b[N];
int main()
{
int n, q;
cin >> n >> q;
string s;
cin >> s;
while(q --){
int l, r;
cin >> l >> r;
string o = s;
int cnt = 0;
for(int i = l - 1; i <= r - 1; i ++)
{
char c = o[i];
s.insert(i + cnt ++, 1, c);//在索引i的位置插入1个字符c
}
}
cout << s << endl;
return 0;
}