#include <bits/stdc++.h>
using namespace std;
int n, q, hav[26];
string str;
struct Tree {
  int l, r, sum, lazy;
};
struct segmenttree {
  Tree tree[100010 << 2];
  void push_down(int u) {
    int lazy = tree[u].lazy;
    if (lazy != -1) {
      tree[u << 1].lazy = tree[u << 1 | 1].lazy = lazy;
      tree[u << 1].sum = (tree[u << 1].r - tree[u << 1].l + 1) * lazy;
      tree[u << 1 | 1].sum =
          (tree[u << 1 | 1].r - tree[u << 1 | 1].l + 1) * lazy;
      tree[u].lazy = -1;
    }
  }
  void build(int p, int l, int r, int num) {
    tree[p].l = l;
    tree[p].r = r;
    tree[p].lazy = -1;
    if (l == r) {
      int num1 = str[l] - 'a';
      if (num == num1) {
        tree[p].sum = 1;
      } else {
        tree[p].sum = 0;
      }
      return;
    }
    int mid = (l + r) / 2;
    build(p * 2, l, mid, num);
    build(p * 2 + 1, mid + 1, r, num);
    tree[p].sum = tree[p * 2].sum + tree[p * 2 + 1].sum;
  }
  int ask(int p, int l, int r) {
    if (l <= tree[p].l && r >= tree[p].r) {
      return tree[p].sum;
    }
    int res = 0;
    int mid = (tree[p].l + tree[p].r) / 2;
    push_down(p);
    if (l <= mid) {
      res += ask(p * 2, l, r);
    }
    if (r > mid) {
      res += ask(p * 2 + 1, l, r);
    }
    return res;
  }
  void update(int p, int l, int r, int v) {
    if (l <= tree[p].l && r >= tree[p].r) {
      tree[p].sum = (tree[p].r - tree[p].l + 1) * v;
      tree[p].lazy = v;
      return;
    }
    int mid = (tree[p].l + tree[p].r) / 2;
    push_down(p);
    if (l <= mid) {
      update(p << 1, l, r, v);
    }
    if (r > mid) {
      update(p << 1 | 1, l, r, v);
    }
    tree[p].sum = tree[p << 1].sum + tree[p << 1 | 1].sum;
  }
} tra[26];
int main() {
  scanf("%d%d", &n, &q);
  cin >> str;
  for (int i = 0; i < 26; i++) {
    tra[i].build(1, 0, n - 1, i);
  }
  while (q--) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    x--, y--;
    for (int i = 0; i < 26; i++) {
      hav[i] = tra[i].ask(1, x, y);
      tra[i].update(1, x, y, 0);
    }
    int l = x;
    if (z) {
      for (int i = 0; i < 26; i++) {
        if (hav[i]) {
          tra[i].update(1, l, l + hav[i] - 1, 1);
          l += hav[i];
        }
      }
    } else {
      for (int i = 25; i >= 0; i--) {
        if (hav[i]) {
          tra[i].update(1, l, l + hav[i] - 1, 1);
          l += hav[i];
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      if (tra[j].ask(1, i, i)) {
        printf("%c", j + 'a');
        break;
      }
    }
  }
  printf("\n");
  return 0;
}
