#include <bits/stdc++.h>
char str[100004];
int cnt[200000][26], tag[200000], ls[200000], rs[200000], segcnt;
void build(int &t, int l, int r) {
  t = segcnt++;
  if (l < r) {
    int mid = (l + r) >> 1, i;
    tag[t] = -1;
    build(ls[t], l, mid), build(rs[t], mid + 1, r);
    for (i = 0; i < 26; i++) cnt[t][i] = cnt[ls[t]][i] + cnt[rs[t]][i];
  } else
    tag[t] = str[l] - 'a', cnt[t][tag[t]] = 1;
}
inline void pushdown(int t, int l, int r) {
  if (ls[t] && tag[t] >= 0) {
    int mid = (l + r) >> 1, i;
    for (i = 0; i < 26; i++) cnt[ls[t]][i] = cnt[rs[t]][i] = 0;
    cnt[ls[t]][tag[t]] = mid - l + 1;
    cnt[rs[t]][tag[t]] = r - mid;
    tag[ls[t]] = tag[rs[t]] = tag[t];
    tag[t] = -1;
  }
}
void query(int t, int l, int r, int _l, int _r, int *res) {
  int mid = (l + r) >> 1, i, c[26];
  if (_l == l && _r == r) {
    for (i = 0; i < 26; i++) res[i] += cnt[t][i];
    return;
  }
  pushdown(t, l, r);
  if (_r <= mid)
    query(ls[t], l, mid, _l, _r, res);
  else if (_l > mid)
    query(rs[t], mid + 1, r, _l, _r, res);
  else {
    for (i = 0; i < 26; i++) c[i] = 0;
    query(ls[t], l, mid, _l, mid, res);
    query(rs[t], mid + 1, r, mid + 1, _r, c);
    for (i = 0; i < 26; i++) res[i] += c[i];
  }
}
void modify(int t, int l, int r, int _l, int _r, int k) {
  int mid = (l + r) >> 1, i;
  if (_l == l && _r == r) {
    for (i = 0; i < 26; i++) cnt[t][i] = 0;
    cnt[t][k] = r - l + 1, tag[t] = k;
    return;
  }
  pushdown(t, l, r);
  if (_r <= mid)
    modify(ls[t], l, mid, _l, _r, k);
  else if (_l > mid)
    modify(rs[t], mid + 1, r, _l, _r, k);
  else
    modify(ls[t], l, mid, _l, mid, k),
        modify(rs[t], mid + 1, r, mid + 1, _r, k);
  for (i = 0; i < 26; i++) cnt[t][i] = cnt[ls[t]][i] + cnt[rs[t]][i];
}
void dfs(int t, int l, int r) {
  if (l == r)
    putchar(tag[t] + 'a');
  else {
    int mid = (l + r) >> 1;
    pushdown(t, l, r);
    dfs(ls[t], l, mid), dfs(rs[t], mid + 1, r);
  }
}
int main() {
  int N, M, root, l, r, k, i, c[26];
  scanf("%d%d%s", &N, &M, str + 1);
  build(root, 1, N);
  while (M--) {
    scanf("%d%d%d", &l, &r, &k);
    for (i = 0; i < 26; i++) c[i] = 0;
    query(root, 1, N, l, r, c), r = 0;
    if (k == 1) {
      for (i = 0; i < 26; i++)
        if (c[i]) modify(root, 1, N, l + r, l + r + c[i] - 1, i), r += c[i];
    } else {
      for (i = 25; i >= 0; i--)
        if (c[i]) modify(root, 1, N, l + r, l + r + c[i] - 1, i), r += c[i];
    }
  }
  dfs(root, 1, N);
  return 0;
}
