#include <bits/stdc++.h>
using namespace std;
const int maxn = 4 * 1e5 + 1000;
int a[maxn][30], lazy[maxn][30];
string se;
void shift(int v, int s, int e, int p) {
  if (lazy[v][p] == 0) return;
  a[2 * v][p] = 0;
  a[2 * v + 1][p] = 0;
  if (lazy[v][p] == 1) {
    int mid = (s + e) / 2;
    a[2 * v][p] = mid - s;
    a[2 * v + 1][p] = e - mid;
  }
  lazy[2 * v][p] = lazy[v][p];
  lazy[2 * v + 1][p] = lazy[v][p];
  lazy[v][p] = 0;
}
int get(int v, int s, int e, int qs, int qe, int p) {
  if (qs >= e || qe <= s) return 0;
  if (qs <= s && qe >= e) return a[v][p];
  int mid = (s + e) / 2;
  shift(v, s, e, p);
  return get(2 * v, s, mid, qs, qe, p) + get(2 * v + 1, mid, e, qs, qe, p);
}
void upd(int v, int s, int e, int qs, int qe, int p, int k) {
  if (qs >= e || qe <= s) return;
  if (qs <= s && qe >= e) {
    a[v][p] = (k == 1 ? e - s : 0);
    lazy[v][p] = k;
    return;
  }
  int mid = (s + e) / 2;
  shift(v, s, e, p);
  upd(2 * v, s, mid, qs, qe, p, k);
  upd(2 * v + 1, mid, e, qs, qe, p, k);
  a[v][p] = a[2 * v][p] + a[2 * v + 1][p];
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m >> se;
  for (int i = 0; i < n; i++) upd(1, 0, n, i, i + 1, se[i] - 'a', 1);
  for (int z = 0; z < m; z++) {
    int l, r, k;
    cin >> l >> r >> k;
    l--;
    int st = l;
    if (k == 1) {
      for (int j = 0; j < 26; j++) {
        int num = get(1, 0, n, l, r, j);
        upd(1, 0, n, l, r, j, -1);
        upd(1, 0, n, st, st + num, j, 1);
        st += num;
      }
    } else {
      for (int j = 25; j >= 0; j--) {
        int num = get(1, 0, n, l, r, j);
        upd(1, 0, n, l, r, j, -1);
        upd(1, 0, n, st, st + num, j, 1);
        st += num;
      }
    }
  }
  string t = "";
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 26; j++) {
      if (get(1, 0, n, i, i + 1, j) == 1) {
        t += j + 'a';
        break;
      }
    }
  cout << t << endl;
  return 0;
}
