#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10, Maxn = 1e5 + 10, SQ = 360, lg = 22;
const int mod = 1e9 + 7;
const long long inf = 1e18 + 10;
int n, seg[27][maxn << 2], lazy[27][maxn << 2];
string s;
void Build(int id = 1, int l = 0, int r = n) {
  if (r - l == 1) {
    seg[s[l] - 'a'][id] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  Build(id * 2, l, mid), Build(id * 2 + 1, mid, r);
  for (int i = 0; i < 27; i++) {
    seg[i][id] = seg[i][id * 2] + seg[i][id * 2 + 1];
  }
}
void fix(int val, int i, int id, int l, int r) {
  seg[i][id] = (r - l) * val;
  lazy[i][id] = val;
}
void relax(int i, int id, int l, int r) {
  if (lazy[i][id] == -1) return;
  int mid = (l + r) >> 1;
  fix(lazy[i][id], i, id * 2, l, mid);
  fix(lazy[i][id], i, id * 2 + 1, mid, r);
  lazy[i][id] = -1;
}
void update(int s, int e, int val, int i, int id = 1, int l = 0, int r = n) {
  if (s <= l && r <= e) {
    fix(val, i, id, l, r);
    return;
  }
  if (r <= s || e <= l) return;
  int mid = (l + r) >> 1;
  relax(i, id, l, r);
  update(s, e, val, i, id * 2, l, mid);
  update(s, e, val, i, id * 2 + 1, mid, r);
  seg[i][id] = seg[i][id * 2] + seg[i][id * 2 + 1];
}
int get(int s, int e, int i, int id = 1, int l = 0, int r = n) {
  if (s <= l && r <= e) return seg[i][id];
  if (r <= s || e <= l) return 0;
  int mid = (l + r) >> 1;
  relax(i, id, l, r);
  return get(s, e, i, id * 2, l, mid) + get(s, e, i, id * 2 + 1, mid, r);
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int q;
  cin >> n >> q;
  for (int i = 0; i < 27; i++)
    for (int j = 0; j < maxn << 2; j++) lazy[i][j] = -1;
  cin >> s;
  Build();
  while (q--) {
    int l, r, typ;
    cin >> l >> r >> typ;
    l--;
    int indx = l;
    if (typ) {
      for (int i = 0; i < 27; i++) {
        int x = get(l, r, i);
        if (x) {
          update(l, r, 0, i);
          update(indx, indx + x, 1, i);
          indx += x;
        }
      }
    } else {
      for (int i = 26; i >= 0; i--) {
        int x = get(l, r, i);
        if (x) {
          update(l, r, 0, i);
          update(indx, indx + x, 1, i);
          indx += x;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 27; j++) {
      if (get(i, i + 1, j)) {
        char x = 'a' + j;
        cout << x;
        break;
      }
    }
  }
  cout << "\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;
const int maxn = 1e5 + 10, Maxn = 1e5 + 10, SQ = 360, lg = 22;
const int mod = 1e9 + 7;
const long long inf = 1e18 + 10;
int n, seg[27][maxn << 2], lazy[27][maxn << 2];
string s;
void Build(int id = 1, int l = 0, int r = n) {
  if (r - l == 1) {
    seg[s[l] - 'a'][id] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  Build(id * 2, l, mid), Build(id * 2 + 1, mid, r);
  for (int i = 0; i < 27; i++) {
    seg[i][id] = seg[i][id * 2] + seg[i][id * 2 + 1];
  }
}
void fix(int val, int i, int id, int l, int r) {
  seg[i][id] = (r - l) * val;
  lazy[i][id] = val;
}
void relax(int i, int id, int l, int r) {
  if (lazy[i][id] == -1) return;
  int mid = (l + r) >> 1;
  fix(lazy[i][id], i, id * 2, l, mid);
  fix(lazy[i][id], i, id * 2 + 1, mid, r);
  lazy[i][id] = -1;
}
void update(int s, int e, int val, int i, int id = 1, int l = 0, int r = n) {
  if (s <= l && r <= e) {
    fix(val, i, id, l, r);
    return;
  }
  if (r <= s || e <= l) return;
  int mid = (l + r) >> 1;
  relax(i, id, l, r);
  update(s, e, val, i, id * 2, l, mid);
  update(s, e, val, i, id * 2 + 1, mid, r);
  seg[i][id] = seg[i][id * 2] + seg[i][id * 2 + 1];
}
int get(int s, int e, int i, int id = 1, int l = 0, int r = n) {
  if (s <= l && r <= e) return seg[i][id];
  if (r <= s || e <= l) return 0;
  int mid = (l + r) >> 1;
  relax(i, id, l, r);
  return get(s, e, i, id * 2, l, mid) + get(s, e, i, id * 2 + 1, mid, r);
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int q;
  cin >> n >> q;
  for (int i = 0; i < 27; i++)
    for (int j = 0; j < maxn << 2; j++) lazy[i][j] = -1;
  cin >> s;
  Build();
  while (q--) {
    int l, r, typ;
    cin >> l >> r >> typ;
    l--;
    int indx = l;
    if (typ) {
      for (int i = 0; i < 27; i++) {
        int x = get(l, r, i);
        if (x) {
          update(l, r, 0, i);
          update(indx, indx + x, 1, i);
          indx += x;
        }
      }
    } else {
      for (int i = 26; i >= 0; i--) {
        int x = get(l, r, i);
        if (x) {
          update(l, r, 0, i);
          update(indx, indx + x, 1, i);
          indx += x;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 27; j++) {
      if (get(i, i + 1, j)) {
        char x = 'a' + j;
        cout << x;
        break;
      }
    }
  }
  cout << "\n";
  return 0;
}

```