#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
struct Tree {
  int l, r, lazy, sum;
};
char str[MAXN];
struct Segment_tree {
  Tree tree[MAXN << 2];
  void pushup(int root) {
    tree[root].sum = tree[root << 1].sum + tree[root << 1 | 1].sum;
  }
  void pushdown(int root) {
    if (~tree[root].lazy) {
      tree[root << 1 | 1].lazy = tree[root << 1].lazy = tree[root].lazy;
      tree[root << 1].sum =
          (tree[root << 1].r - tree[root << 1].l) * tree[root].lazy;
      tree[root << 1 | 1].sum =
          (tree[root << 1 | 1].r - tree[root << 1 | 1].l) * tree[root].lazy;
      tree[root].lazy = -1;
    }
  }
  void build(int k, int l, int r, int val) {
    tree[k].l = l, tree[k].r = r;
    tree[k].lazy = -1;
    if (r - l == 1) {
      if (str[l] - 'a' == val)
        tree[k].sum = 1;
      else
        tree[k].sum = 0;
    } else {
      build(k << 1, l, l + (r - l) / 2, val);
      build(k << 1 | 1, l + (r - l) / 2, r, val);
      pushup(k);
    }
  }
  void update(int k, int ql, int qr, int val) {
    int &l = tree[k].l, &r = tree[k].r;
    if (l >= ql && r <= qr) {
      tree[k].lazy = val;
      tree[k].sum = (r - l) * val;
    } else if (l < qr && r > ql) {
      pushdown(k);
      update(k << 1, ql, qr, val);
      update(k << 1 | 1, ql, qr, val);
      pushup(k);
    }
  }
  int query(int k, int ql, int qr) {
    int &l = tree[k].l, &r = tree[k].r;
    if (l >= ql && r <= qr)
      return tree[k].sum;
    else if (l < qr && r > ql) {
      pushdown(k);
      return query(k << 1, ql, qr) + query(k << 1 | 1, ql, qr);
    }
    return 0;
  }
} alpha[26];
int record[26];
void solve() {
  int n, q, a, b, c;
  scanf("%d%d", &n, &q);
  scanf("%s", str);
  for (int i = 0; i < 26; ++i) alpha[i].build(1, 0, n, i);
  for (int i = 0; i < q; ++i) {
    memset(record, 0, sizeof(record));
    scanf("%d%d%d", &a, &b, &c);
    --a;
    for (int i = 0; i < 26; ++i) {
      record[i] = alpha[i].query(1, a, b);
      alpha[i].update(1, a, b, 0);
    }
    if (c) {
      for (int i = 0; i < 26; a += record[i], ++i)
        if (record[i]) alpha[i].update(1, a, a + record[i], 1);
    } else {
      for (int i = 25; i >= 0; a += record[i], --i)
        if (record[i]) alpha[i].update(1, a, a + record[i], 1);
    }
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j) {
      if (alpha[j].query(1, i, i + 1)) {
        printf("%c", 'a' + j);
        break;
      }
    }
}
int main(void) { solve(); }
