Problem: This task is very simple. Given a string S of length n and q queries each query is on the format i j k which means sort the substring consisting of the characters from i to j in non-decreasing order if k = 1 or in non-increasing order if k = 0.

Output the final string after applying the queries.

Input

The first line will contain two integers n, q (1 ≤ n ≤ 105, 0 ≤ q ≤ 50 000), the length of the string and the number of queries respectively. 

Next line contains a string S itself. It contains only lowercase English letters.

Next q lines will contain three integers each i, j, k (1 ≤ i ≤ j ≤ n, <image>).

Output

Output one line, the string S after applying the queries.

Examples

Input

10 5
abacdabcda
7 10 0
5 8 1
1 4 0
3 6 0
7 10 1


Output

cbcaaaabdd

Input

10 1
agjucbvdfk
1 10 1


Output

abcdfgjkuv

Note

First sample test explanation:

<image>

<image>

<image>

<image>

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
const int infi = 1e9 + 7;
const long long infl = 1e18 + 7;
string s;
int used[100500];
struct seg {
  int l, r, type;
  vector<int> cnt;
  seg() { cnt.resize(26, 0); }
  seg(int l, int r) : l(l), r(r) {}
  seg(int l, int r, int type) : l(l), r(r), type(type) { cnt.resize(26, 0); }
  int sum() {
    int ans = 0;
    for (int i = 0; i < (26); ++i) ans += cnt[i];
    return ans;
  }
  int good() { return l <= r && sum(); }
  int &operator[](int i) { return cnt[i]; }
  const int &operator[](int i) const { return cnt[i]; }
  bool operator<(const seg &a) const { return l < a.l || l == a.l && r < a.r; }
};
pair<seg, seg> get(seg &a, seg &b) {
  pair<seg, seg> ans;
  if (a.type) {
    int j = 0;
    int i = a.l;
    for (j = 0; j < 26 && i < b.l; ++j) {
      int q = min(b.l - i, a[j]);
      ans.first[j] += q;
      a[j] -= q;
      i += q;
    }
    i = a.r;
    for (j = 25; j >= 0 && i > b.r; --j) {
      int q = min(i - b.r, a[j]);
      ans.second[j] += q;
      a[j] -= q;
      i -= q;
    }
  } else {
    int j;
    int i = a.l;
    for (j = 25; j >= 0 && i < b.l; --j) {
      int q = min(b.l - i, a[j]);
      ans.first[j] += q;
      a[j] -= q;
      i += q;
    }
    i = a.r;
    for (j = 0; j < 26 && i > b.r; ++j) {
      int q = min(i - b.r, a[j]);
      ans.second[j] += q;
      a[j] -= q;
      i -= q;
    }
  }
  for (int j = 0; j < (26); ++j) b[j] += a[j];
  ans.first.l = a.l, ans.first.r = min(a.r, b.l - 1);
  ans.second.l = max(a.l, b.r + 1), ans.second.r = a.r;
  ans.first.type = ans.second.type = a.type;
  return ans;
}
set<seg> all_seg;
void srt(int l, int r, int k) {
  seg ans = seg(l, r, k);
  for (int i = l; i <= r;) {
    if (!used[i]) {
      used[i] = 1;
      ans[s[i]]++;
      ++i;
      continue;
    }
    auto it = all_seg.lower_bound(seg(i + 1, -1));
    --it;
    seg cur = *it;
    all_seg.erase(it);
    auto a = get(cur, ans);
    if (a.first.good()) all_seg.insert(a.first);
    if (a.second.good()) all_seg.insert(a.second);
    i = cur.r + 1;
  }
  all_seg.insert(ans);
  return;
}
void rep(char c, int cnt, string &ans) {
  for (int i = 0; i < (cnt); ++i) ans += c;
  return;
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < (n); ++i) s[i] -= 'a';
  for (int i = 0; i < (q); ++i) {
    int l, r, k;
    cin >> l >> r >> k;
    srt(l - 1, r - 1, k);
  }
  string ans;
  for (int i = 0; i < n;) {
    if (!used[i]) {
      ans += s[i] + 'a';
      ++i;
      continue;
    }
    auto it = all_seg.lower_bound(seg(i, -1));
    if (it->type)
      for (int j = 0; j < (26); ++j) rep(j + 'a', it->operator[](j), ans);
    else
      for (int j = (25); j >= 0; --j) rep(j + 'a', it->operator[](j), ans);
    i = it->r + 1;
  }
  cout << ans;
  return 0;
}