#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int n, q;
string s;
vector<int> pos[26];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout.precision(30);
  cerr.precision(7);
  ;
  cin >> n >> q >> s;
  for (int i = 0; i < n; ++i) pos[s[i] - 'a'].push_back(i);
  while (q--) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    if (c) {
      int tmp = a;
      for (int i = 0; i < 26; ++i) {
        int x = lower_bound(pos[i].begin(), pos[i].end(), a) - pos[i].begin();
        int y = upper_bound(pos[i].begin(), pos[i].end(), b) - pos[i].begin();
        for (int j = x; j < y; ++j) pos[i][j] = tmp++;
      }
    } else {
      int tmp = b;
      for (int i = 0; i < 26; ++i) {
        int x = lower_bound(pos[i].begin(), pos[i].end(), a) - pos[i].begin();
        int y = upper_bound(pos[i].begin(), pos[i].end(), b) - pos[i].begin();
        for (int j = y - 1; j >= x; --j) pos[i][j] = tmp--;
      }
    }
  }
  for (int i = 0; i < 26; i++)
    for (auto a : pos[i]) s[a] = ('a' + i);
  cout << s << endl;
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int n, q;
string s;
vector<int> pos[26];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout.precision(30);
  cerr.precision(7);
  ;
  cin >> n >> q >> s;
  for (int i = 0; i < n; ++i) pos[s[i] - 'a'].push_back(i);
  while (q--) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    if (c) {
      int tmp = a;
      for (int i = 0; i < 26; ++i) {
        int x = lower_bound(pos[i].begin(), pos[i].end(), a) - pos[i].begin();
        int y = upper_bound(pos[i].begin(), pos[i].end(), b) - pos[i].begin();
        for (int j = x; j < y; ++j) pos[i][j] = tmp++;
      }
    } else {
      int tmp = b;
      for (int i = 0; i < 26; ++i) {
        int x = lower_bound(pos[i].begin(), pos[i].end(), a) - pos[i].begin();
        int y = upper_bound(pos[i].begin(), pos[i].end(), b) - pos[i].begin();
        for (int j = y - 1; j >= x; --j) pos[i][j] = tmp--;
      }
    }
  }
  for (int i = 0; i < 26; i++)
    for (auto a : pos[i]) s[a] = ('a' + i);
  cout << s << endl;
  return 0;
}

```