#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 20;
int n, q;
string s;
int seg[N << 2][50], lz[N << 2][50];
void build(int id = 1, int l = 1, int r = n) {
  if (l == r) {
    seg[id][s[l - 1] - 'a'] = 1;
    return;
  }
  int mid = l + r >> 1;
  build(id << 1, l, mid);
  build(id << 1 | 1, mid + 1, r);
  for (int i = 0; i < 26; i++)
    seg[id][i] = seg[id << 1][i] + seg[id << 1 | 1][i];
}
void shift(int id, int l, int r, int c) {
  seg[id][c] = lz[id][c] * (r - l + 1);
  if (l ^ r) lz[id << 1][c] = lz[id][c], lz[id << 1 | 1][c] = lz[id][c];
  lz[id][c] = -1;
  return;
}
void upd(int lq, int rq, int c, int val, int id = 1, int l = 1, int r = n) {
  if (lz[id][c] != -1) shift(id, l, r, c);
  if (lq > r || rq < l) return;
  if (l >= lq && r <= rq) {
    lz[id][c] = val;
    shift(id, l, r, c);
    return;
  }
  int mid = l + r >> 1;
  upd(lq, rq, c, val, id << 1, l, mid);
  upd(lq, rq, c, val, id << 1 | 1, mid + 1, r);
  seg[id][c] = seg[id << 1][c] + seg[id << 1 | 1][c];
}
int get(int lq, int rq, int c, int id = 1, int l = 1, int r = n) {
  if (lz[id][c] != -1) shift(id, l, r, c);
  if (lq > r || l > rq) return 0;
  if (l >= lq && r <= rq) return seg[id][c];
  int mid = l + r >> 1;
  return get(lq, rq, c, id << 1, l, mid) +
         get(lq, rq, c, id << 1 | 1, mid + 1, r);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  memset(lz, -1, sizeof lz);
  cin >> n >> q >> s;
  build();
  while (q--) {
    int lq, rq, val;
    cin >> lq >> rq >> val;
    if (!val) {
      int T = lq;
      for (int i = 25; ~i; i--) {
        int cnt = get(lq, rq, i);
        upd(lq, rq, i, 0);
        if (cnt) upd(T, T + cnt - 1, i, 1);
        T += cnt;
      }
    } else {
      int T = lq;
      for (int i = 0; i < 26; i++) {
        int cnt = get(lq, rq, i);
        upd(lq, rq, i, 0);
        if (cnt) upd(T, T + cnt - 1, i, 1);
        T += cnt;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 26; j++)
      if (get(i, i, j)) cout << (char)(j + 'a');
  cout << endl;
  return 0;
}
