#include <bits/stdc++.h>
const int MaxN = 1e5 + 10;
struct node {
  int l, r;
  int sum, tag;
};
int n, m, a[MaxN];
char s[MaxN], ans[MaxN];
struct SegmentTree {
  node t[MaxN << 2];
  void pushup(int id) { t[id].sum = t[id << 1].sum + t[id << 1 | 1].sum; }
  void build(int id, int l, int r, int val) {
    t[id].l = l, t[id].r = r, t[id].tag = -1;
    if (l == r) {
      if (val == a[l]) t[id].sum = 1;
      return;
    }
    int mid = (l + r) >> 1;
    build(id << 1, l, mid, val), build(id << 1 | 1, mid + 1, r, val),
        pushup(id);
  }
  void pushdown(int id) {
    if (~t[id].tag) {
      int tag = t[id].tag;
      t[id << 1].tag = t[id << 1 | 1].tag = tag, t[id].tag = -1;
      t[id << 1].sum = tag * (t[id << 1].r - t[id << 1].l + 1);
      t[id << 1 | 1].sum = tag * (t[id << 1 | 1].r - t[id << 1 | 1].l + 1);
    }
  }
  void modify(int id, int l, int r, int val) {
    if (t[id].l > r || l > t[id].r) return;
    if (l <= t[id].l && t[id].r <= r) {
      t[id].tag = val, t[id].sum = val * (t[id].r - t[id].l + 1);
      return;
    }
    pushdown(id), modify(id << 1, l, r, val);
    modify(id << 1 | 1, l, r, val), pushup(id);
  }
  int query(int id, int l, int r) {
    if (t[id].l > r || l > t[id].r) return 0;
    if (l <= t[id].l && t[id].r <= r) return t[id].sum;
    pushdown(id);
    return query(id << 1, l, r) + query(id << 1 | 1, l, r);
  }
} T[27];
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') ch = getchar();
  while (ch <= '9' && ch >= '0')
    x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return x;
}
int main() {
  scanf("%d%d%s", &n, &m, s + 1);
  for (int i = 1; i <= n; i++) a[i] = s[i] - 'a' + 1;
  for (int i = 1; i <= 26; i++) T[i].build(1, 1, n, i);
  while (m--) {
    int l = read(), r = read(), op = read();
    if (op == 1) {
      int cnt[27] = {};
      for (int i = 1; i <= 26; i++)
        cnt[i] = T[i].query(1, l, r), T[i].modify(1, l, r, 0);
      int now = l;
      for (int i = 1; i <= 26; i++) {
        if (cnt[i]) T[i].modify(1, now, now + cnt[i] - 1, 1), now += cnt[i];
      }
    } else {
      int cnt[27] = {};
      for (int i = 26; i; i--)
        cnt[i] = T[i].query(1, l, r), T[i].modify(1, l, r, 0);
      int now = l;
      for (int i = 26; i; i--) {
        if (cnt[i]) T[i].modify(1, now, now + cnt[i] - 1, 1), now += cnt[i];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 26; j++) {
      if (T[j].query(1, i, i)) {
        putchar(j + 'a' - 1);
        break;
      }
    }
  }
  return 0;
}
