#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;
}

### Prompt

Your task is to create a CPP solution to the following 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>

### Response

```cpp
#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;
}

```