//LongvnXD
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define ii pair<int, int>
#define plll pair<ll, pll>
#define fi first
#define se second
#define x first
#define y second
#define all(v) v.begin(), v.end()
const int N = 2e5 + 5;
const int oo = 1e9 + 9;
using namespace std;
string s;
int n, m, k;
struct dl { int a, b, c; } a[N];
int calc(int j) {
for(int i = n; i; --i) {
if(a[i].c > j) continue;
if(a[i].b - a[i].a + a[i].c <= j) j -= (a[i].b - a[i].a);
else
j = a[i].b - (a[i].b - a[i].a + a[i].c - j);
}
return j;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> k >> m >> s >> n;
for(int i = 1; i <= n; ++i) cin >> a[i].a >> a[i].b >> a[i].c;
for(int i = 0; i < k; ++i) cout << s[calc(i)];
return 0;
}