#include <bits/stdc++.h>
using namespace std;
struct node {
  int lazy;
  int cnt[26];
};
node tree[(1 << 19)];
void insert_element(int l, int r, int e, int p = 1, int st = 1,
                    int ed = 100001) {
  if (st == ed) {
    tree[p].lazy = 0;
    memset(tree[p].cnt, 0, sizeof(tree[p].cnt));
    tree[p].cnt[e]++;
    return;
  }
  if (st >= l && ed <= r) {
    tree[p].lazy = 1;
    memset(tree[p].cnt, 0, sizeof(tree[p].cnt));
    tree[p].cnt[e] = ed - st + 1;
    return;
  }
  int mid = (st + ed) / 2;
  if (tree[p].lazy) {
    for (int i = 0; i < 26; i++) {
      if (tree[p].cnt[i]) {
        tree[p * 2].cnt[i] = mid - st + 1;
        tree[p * 2 + 1].cnt[i] = ed - mid;
      } else {
        tree[p * 2].cnt[i] = tree[p * 2 + 1].cnt[i] = 0;
      }
    }
    tree[p * 2].lazy = tree[p * 2 + 1].lazy = 1;
  }
  if (l <= mid) {
    insert_element(l, r, e, p * 2, st, mid);
  }
  if (r > mid) {
    insert_element(l, r, e, p * 2 + 1, mid + 1, ed);
  }
  for (int i = 0; !tree[p].lazy && i < 26; i++) {
    tree[p].cnt[i] = tree[p * 2].cnt[i] + tree[p * 2 + 1].cnt[i];
  }
  tree[p].lazy = 0;
}
int get_element(int l, int r, int e, int p = 1, int st = 1, int ed = 100001) {
  if (st == ed) {
    return tree[p].cnt[e];
  }
  if (st >= l && ed <= r) {
    return tree[p].cnt[e];
  }
  int mid = (st + ed) / 2;
  if (tree[p].lazy) {
    for (int i = 0; i < 26; i++) {
      if (tree[p].cnt[i]) {
        tree[p * 2].cnt[i] = mid - st + 1;
        tree[p * 2 + 1].cnt[i] = ed - mid;
      } else {
        tree[p * 2].cnt[i] = tree[p * 2 + 1].cnt[i] = 0;
      }
    }
    tree[p * 2].lazy = tree[p * 2 + 1].lazy = 1;
  }
  int sum = 0;
  if (l <= mid) {
    sum += get_element(l, r, e, p * 2, st, mid);
  }
  if (r > mid) {
    sum += get_element(l, r, e, p * 2 + 1, mid + 1, ed);
  }
  for (int i = 0; !tree[p].lazy && i < 26; i++) {
    tree[p].cnt[i] = tree[p * 2].cnt[i] + tree[p * 2 + 1].cnt[i];
  }
  tree[p].lazy = 0;
  return sum;
}
char s[100001];
int cnt[26];
int main() {
  int n, q;
  int l, r, k;
  scanf("%d%d", &n, &q);
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    insert_element(i + 1, i + 1, s[i] - 'a');
  }
  while (q--) {
    scanf("%d%d%d", &l, &r, &k);
    for (int i = 0; i < 26; i++) {
      cnt[i] = get_element(l, r, i);
    }
    if (k) {
      for (int i = 0; i < 26; i++) {
        if (cnt[i]) {
          insert_element(l, l + cnt[i] - 1, i);
          l += cnt[i];
        }
      }
    } else {
      for (int i = 25; i >= 0; i--) {
        if (cnt[i]) {
          insert_element(l, l + cnt[i] - 1, i);
          l += cnt[i];
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 26; j++) {
      if (get_element(i, i, j)) putchar((char)j + 'a');
    }
  }
}
