#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const int N = 1e5 + 10;
struct Segment_Tree {
  struct Tree {
    int l, r;
    int sum, tag;
  } tr[N * 4];
  void push_up(int x) { tr[x].sum = tr[x << 1].sum + tr[x << 1 | 1].sum; }
  void push_down(int x) {
    int l = x << 1, r = x << 1 | 1, tag = tr[x].tag;
    if (tag == -1) return;
    tr[l].sum = tag * (tr[l].r - tr[l].l + 1);
    tr[l].tag = tag;
    tr[r].sum = tag * (tr[r].r - tr[r].l + 1);
    tr[r].tag = tag;
    tr[x].tag = -1;
  }
  void build(int x, int l, int r) {
    tr[x] = (Tree){l, r, 0, 0};
    if (l == r) return;
    int mid = (l + r) / 2;
    if (l <= mid) build(x << 1, l, mid);
    if (mid < r) build(x << 1 | 1, mid + 1, r);
    push_up(x);
  }
  void add(int x, int l, int r, int k) {
    if (l <= tr[x].l && tr[x].r <= r) {
      tr[x].sum = k * (tr[x].r - tr[x].l + 1);
      tr[x].tag = k;
      return;
    }
    push_down(x);
    int mid = (tr[x].l + tr[x].r) / 2;
    if (l <= mid) add(x << 1, l, r, k);
    if (mid < r) add(x << 1 | 1, l, r, k);
    push_up(x);
  }
  int sum(int x, int l, int r) {
    if (l <= tr[x].l && tr[x].r <= r) return tr[x].sum;
    push_down(x);
    int mid = (tr[x].l + tr[x].r) / 2, Sum = 0;
    if (l <= mid) Sum += sum(x << 1, l, r);
    if (mid < r) Sum += sum(x << 1 | 1, l, r);
    return Sum;
  }
} tr[26];
void ans(int x, int l, int r) {
  if (l == r) {
    for (int i = 0; i < 26; i++) {
      if (tr[i].tr[x].sum == 0) continue;
      cout << (char)('a' + i);
      return;
    }
  }
  for (int i = 0; i < 26; i++) {
    tr[i].push_down(x);
  }
  int mid = (l + r) / 2;
  if (l <= mid) ans(x << 1, l, mid);
  if (mid < r) ans(x << 1 | 1, mid + 1, r);
}
int n, q;
int main() {
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 0; i < 26; i++) {
    tr[i].build(1, 1, n);
  }
  for (int i = 1; i <= n; i++) {
    char x;
    cin >> x;
    tr[x - 'a'].add(1, i, i, 1);
  }
  while (q--) {
    int op, x, y;
    cin >> x >> y >> op;
    if (op == 1) {
      int sum, cnt = x;
      for (int i = 0; i < 26; i++) {
        sum = tr[i].sum(1, x, y);
        if (sum == 0) continue;
        tr[i].add(1, x, y, 0);
        tr[i].add(1, cnt, cnt + sum - 1, 1);
        cnt += sum;
      }
    }
    if (op == 0) {
      int sum, cnt = x;
      for (int i = 25; i >= 0; i--) {
        sum = tr[i].sum(1, x, y);
        if (sum == 0) continue;
        tr[i].add(1, x, y, 0);
        tr[i].add(1, cnt, cnt + sum - 1, 1);
        cnt += sum;
      }
    }
  }
  ans(1, 1, n);
  return 0;
}
