#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, m, L, R, pos;
int op, Op[maxn], val[100];
char a[maxn];
set<int> s;
struct SegmentTree {
  int rt[maxn], lc[maxn * 40], rc[maxn * 40], sum[maxn * 40], rub[maxn * 40],
      tot, cnt = 0;
  int New() {
    if (cnt) return rub[cnt--];
    return ++tot;
  }
  void del(int& p) {
    lc[p] = rc[p] = sum[p] = 0;
    rub[++cnt] = p;
    p = 0;
  }
  int merge(int p, int& q, int l, int r) {
    if (!p || !q) return p + q;
    sum[p] += sum[q];
    if (l == r) {
      del(q);
      return p;
    }
    int mid = l + r >> 1;
    lc[p] = merge(lc[p], lc[q], l, mid);
    rc[p] = merge(rc[p], rc[q], mid + 1, r);
    del(q);
    return p;
  }
  void pushUp(int p) { sum[p] = sum[lc[p]] + sum[rc[p]]; }
  void update(int& p, int l, int r, int x) {
    if (!p) p = New();
    if (l == r) {
      sum[p]++;
      return;
    }
    int mid = l + r >> 1;
    if (x <= mid)
      update(lc[p], l, mid, x);
    else
      update(rc[p], mid + 1, r, x);
    pushUp(p);
  }
  int query(int p, int l, int r) {
    if (l == r) return l;
    int mid = l + r >> 1;
    if (lc[p])
      return query(lc[p], l, mid);
    else
      return query(rc[p], mid + 1, r);
  }
  void split(int p, int& q, int k, int op, int l, int r) {
    if (sum[p] == k) return;
    if (!q) q = New();
    sum[q] = sum[p] - k;
    sum[p] = k;
    if (l == r) return;
    int mid = l + r >> 1;
    if (!op) {
      if (sum[rc[p]] >= k) {
        split(rc[p], rc[q], k, op, mid + 1, r);
        lc[q] = lc[p];
        lc[p] = 0;
      } else
        split(lc[p], lc[q], k - sum[rc[p]], op, l, mid);
    } else {
      if (sum[lc[p]] >= k) {
        split(lc[p], lc[q], k, op, l, mid);
        rc[q] = rc[p];
        rc[p] = 0;
      } else
        split(rc[p], rc[q], k - sum[lc[p]], op, mid + 1, r);
    }
  }
} tr;
set<int>::iterator Split(int x) {
  auto v = s.lower_bound(x);
  if (*v == x) return v;
  --v;
  Op[x] = Op[*v];
  tr.split(tr.rt[*v], tr.rt[x], x - *v, Op[x], 1, 26);
  return s.insert(x).first;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  cin >> (a + 1);
  s.insert(n + 1);
  for (int i = 97; i <= 97 + 26 - 1; ++i) val[i - 'a'] = i - 'a' + 1;
  for (int i = 1; i <= n; ++i) {
    tr.update(tr.rt[i], 1, 26, val[a[i] - 'a']);
    s.insert(i);
  }
  for (int i = 1; i <= m; ++i) {
    cin >> L >> R >> op;
    auto st = Split(L);
    auto ed = Split(R + 1);
    for (auto it = ++st; it != ed; ++it) {
      tr.rt[L] = tr.merge(tr.rt[L], tr.rt[*it], 1, 26);
    }
    Op[L] = op;
    s.erase(st, ed);
  }
  for (int i = 1; i <= n; ++i) {
    Split(i);
  }
  for (int i = 1; i <= n; ++i) cout << char(tr.query(tr.rt[i], 1, 26) + 96);
  return 0;
}
