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;
set<int> st[26];
set<int> ed[26];
int calcs[30];
int g(char a) { return a - 'a'; }
int calc(int qi, int qj, int g) {
  int ret = 0;
  while (true) {
    auto e = ed[g].lower_bound(qi);
    if (e == ed[g].end()) break;
    auto s = st[g].upper_bound(*e);
    s--;
    int sv = *s, ev = *e;
    if (sv > qj) break;
    ret += min(qj, ev) - max(qi, sv) + 1;
    st[g].erase(s);
    ed[g].erase(e);
    if (qi > sv) {
      st[g].insert(sv);
      ed[g].insert(qi - 1);
    }
    if (qj < ev) {
      ed[g].insert(ev);
      st[g].insert(qj + 1);
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, q;
  cin >> n >> q;
  string S;
  cin >> S;
  for (int i = 0; i < (int)S.length(); i++) {
    if (i == 0 || S[i] != S[i - 1]) {
      st[g(S[i])].insert(i + 1);
    }
    if (i == (int)S.length() - 1 || S[i] != S[i + 1]) {
      ed[g(S[i])].insert(i + 1);
    }
  }
  for (int i = 0; i < q; i++) {
    int qi, qj, qk;
    cin >> qi >> qj >> qk;
    if (qk > 0) {
      for (int j = g('a'); j <= g('z'); j++) {
        calcs[j] = calc(qi, qj, j);
      }
      for (int j = g('a'); j <= g('z'); j++) {
        if (calcs[j] > 0) {
          st[j].insert(qi);
          ed[j].insert(qi + calcs[j] - 1);
        }
        qi += calcs[j];
      }
    } else {
      for (int j = g('z'); j >= g('a'); j--) {
        calcs[j] = calc(qi, qj, j);
      }
      for (int j = g('z'); j >= g('a'); j--) {
        if (calcs[j] > 0) {
          st[j].insert(qi);
          ed[j].insert(qi + calcs[j] - 1);
        }
        qi += calcs[j];
      }
    }
  }
  for (int i = g('a'); i <= g('z'); i++) {
    while (!st[i].empty()) {
      auto s = st[i].begin();
      auto e = ed[i].begin();
      for (int j = *s; j <= *e; j++) {
        S[j - 1] = i + 'a';
      }
      st[i].erase(s);
      ed[i].erase(e);
    }
  }
  cout << S << endl;
  return 0;
}