#include <bits/stdc++.h>
using namespace std;
vector<int> ioi[30];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  string s;
  cin >> n >> m >> s;
  s = '#' + s;
  for (int _ = 1; _ <= n; _++) ioi[s[_] - 96].push_back(_);
  while (m--) {
    int i, j, k;
    cin >> i >> j >> k;
    if (!k) {
      int gold = i;
      for (int _ = 26; _ >= 1; _--) {
        int lw = lower_bound(ioi[_].begin(), ioi[_].end(), i) - ioi[_].begin();
        int up = upper_bound(ioi[_].begin(), ioi[_].end(), j) - ioi[_].begin();
        for (; lw < up; lw++) ioi[_][lw] = gold++;
      }
    } else {
      int gold = i;
      for (int _ = 1; _ <= 26; _++) {
        int lw = lower_bound(ioi[_].begin(), ioi[_].end(), i) - ioi[_].begin();
        int up = upper_bound(ioi[_].begin(), ioi[_].end(), j) - ioi[_].begin();
        for (; lw < up; lw++) ioi[_][lw] = gold++;
      }
    }
  }
  for (int _ = 1; _ <= 26; _++)
    for (int __ = 0; __ < ioi[_].size(); __++) s[ioi[_][__]] = (char)(_ + 96);
  cout << s.substr(1) << '\n';
  return 0;
}
