#include <bits/stdc++.h>
using namespace std;
string s;
const int N = 5e5;
int n, q, seg[N][26], lazy[N][26];
void Lazy(int i, int p, int l, int r) {
  if (lazy[p][i]) {
    if (lazy[p][i] == 1)
      seg[p][i] = r - l + 1;
    else
      seg[p][i] = 0;
    if (l != r) lazy[p * 2][i] = lazy[2 * p + 1][i] = lazy[p][i];
    lazy[p][i] = 0;
  }
  return;
}
void update(int i, int v, int x, int y, int p = 1, int l = 0, int r = n - 1) {
  Lazy(i, p, l, r);
  if (y < l || x > r) return;
  if (x <= l && y >= r) {
    lazy[p][i] = v;
    Lazy(i, p, l, r);
    return;
  }
  update(i, v, x, y, 2 * p, l, ((l + r) / 2));
  update(i, v, x, y, 2 * p + 1, ((l + r) / 2) + 1, r);
  seg[p][i] = seg[2 * p][i] + seg[2 * p + 1][i];
  return;
}
int get(int i, int x, int y, int p = 1, int l = 0, int r = n - 1) {
  Lazy(i, p, l, r);
  if (y < l || x > r) return 0;
  if (x <= l && y >= r) return seg[p][i];
  return get(i, x, y, 2 * p, l, ((l + r) / 2)) +
         get(i, x, y, 2 * p + 1, ((l + r) / 2) + 1, r);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q >> s;
  for (int i = 0; i < n; i++) update(s[i] - 'a', 1, i, i);
  while (q--) {
    int L, R, x, now = 0;
    cin >> L >> R >> x;
    L--;
    R--;
    for (int i = 0; i < 26; i++) {
      int ii = x * i + (1 - x) * (25 - i);
      int g = get(ii, L, R);
      update(ii, 2, L, R);
      update(ii, 1, L + now, L + now + g - 1);
      now += g;
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 26; j++)
      if (get(j, i, i)) cout << char(j + 'a');
  return 0;
}

### Prompt

Develop a solution in CPP 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>
using namespace std;
string s;
const int N = 5e5;
int n, q, seg[N][26], lazy[N][26];
void Lazy(int i, int p, int l, int r) {
  if (lazy[p][i]) {
    if (lazy[p][i] == 1)
      seg[p][i] = r - l + 1;
    else
      seg[p][i] = 0;
    if (l != r) lazy[p * 2][i] = lazy[2 * p + 1][i] = lazy[p][i];
    lazy[p][i] = 0;
  }
  return;
}
void update(int i, int v, int x, int y, int p = 1, int l = 0, int r = n - 1) {
  Lazy(i, p, l, r);
  if (y < l || x > r) return;
  if (x <= l && y >= r) {
    lazy[p][i] = v;
    Lazy(i, p, l, r);
    return;
  }
  update(i, v, x, y, 2 * p, l, ((l + r) / 2));
  update(i, v, x, y, 2 * p + 1, ((l + r) / 2) + 1, r);
  seg[p][i] = seg[2 * p][i] + seg[2 * p + 1][i];
  return;
}
int get(int i, int x, int y, int p = 1, int l = 0, int r = n - 1) {
  Lazy(i, p, l, r);
  if (y < l || x > r) return 0;
  if (x <= l && y >= r) return seg[p][i];
  return get(i, x, y, 2 * p, l, ((l + r) / 2)) +
         get(i, x, y, 2 * p + 1, ((l + r) / 2) + 1, r);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q >> s;
  for (int i = 0; i < n; i++) update(s[i] - 'a', 1, i, i);
  while (q--) {
    int L, R, x, now = 0;
    cin >> L >> R >> x;
    L--;
    R--;
    for (int i = 0; i < 26; i++) {
      int ii = x * i + (1 - x) * (25 - i);
      int g = get(ii, L, R);
      update(ii, 2, L, R);
      update(ii, 1, L + now, L + now + g - 1);
      now += g;
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 26; j++)
      if (get(j, i, i)) cout << char(j + 'a');
  return 0;
}

```