#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9, MOD = INF + 7;
const int N = 1e5 + 20;
int n;
string str;
int seg[4 * N][26], lazy[4 * N][26];
void build(int c, int id = 1, int s = 0, int e = n) {
  if (e - s < 2) {
    seg[id][c] = (str[s] - 'a' == c);
    return;
  }
  int md = (s + e) / 2;
  build(c, 2 * id, s, md);
  build(c, 2 * id + 1, md, e);
  seg[id][c] = seg[2 * id][c] + seg[2 * id + 1][c];
}
void apply(int val, int id, int c, int s, int e) {
  lazy[id][c] = val;
  seg[id][c] = val * (e - s);
}
void shift(int id, int c, int s, int e) {
  if (lazy[id][c] == -1) return;
  int md = (s + e) / 2;
  apply(lazy[id][c], 2 * id, c, s, md);
  apply(lazy[id][c], 2 * id + 1, c, md, e);
  lazy[id][c] = -1;
}
void update(int l, int r, int val, int c, int id = 1, int s = 0, int e = n) {
  if (l <= s && e <= r) {
    apply(val, id, c, s, e);
    return;
  }
  if (l >= e || s >= r) return;
  shift(id, c, s, e);
  int md = (s + e) / 2;
  update(l, r, val, c, 2 * id, s, md);
  update(l, r, val, c, 2 * id + 1, md, e);
  seg[id][c] = seg[2 * id][c] + seg[2 * id + 1][c];
}
int get(int l, int r, int c, int id = 1, int s = 0, int e = n) {
  if (l <= s && e <= r) return seg[id][c];
  if (l >= e || s >= r) return 0;
  shift(id, c, s, e);
  int md = (s + e) / 2;
  return get(l, r, c, 2 * id, s, md) + get(l, r, c, 2 * id + 1, md, e);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int q;
  cin >> n >> q;
  cin >> str;
  for (int i = 0; i < 26; i++) build(i);
  memset(lazy, -1, sizeof lazy);
  while (q--) {
    int x, y, k;
    cin >> x >> y >> k;
    x--;
    int last = x;
    if (k == 1) {
      for (int i = 0; i < 26; i++) {
        int t = get(x, y, i);
        if (t == 0) continue;
        update(x, y, 0, i);
        update(last, last + t, 1, i);
        last += t;
      }
    } else {
      for (int i = 25; i >= 0; i--) {
        int t = get(x, y, i);
        if (t == 0) continue;
        update(x, y, 0, i);
        update(last, last + t, 1, i);
        last += t;
      }
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 26; j++)
      if (get(i, i + 1, j)) cout << (char)('a' + j);
  cout << "\n";
  return 0;
}
