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;
const int maxn = 4 * 1e5 + 1000;
int a[maxn][30], lazy[maxn][30];
string se;
void shift(int v, int s, int e, int p) {
  if (lazy[v][p] == 0) return;
  a[2 * v][p] = 0;
  a[2 * v + 1][p] = 0;
  if (lazy[v][p] == 1) {
    int mid = (s + e) / 2;
    a[2 * v][p] = mid - s;
    a[2 * v + 1][p] = e - mid;
  }
  lazy[2 * v][p] = lazy[v][p];
  lazy[2 * v + 1][p] = lazy[v][p];
  lazy[v][p] = 0;
}
int get(int v, int s, int e, int qs, int qe, int p) {
  if (qs >= e || qe <= s) return 0;
  if (qs <= s && qe >= e) return a[v][p];
  int mid = (s + e) / 2;
  shift(v, s, e, p);
  return get(2 * v, s, mid, qs, qe, p) + get(2 * v + 1, mid, e, qs, qe, p);
}
void upd(int v, int s, int e, int qs, int qe, int p, int k) {
  if (qs >= e || qe <= s) return;
  if (qs <= s && qe >= e) {
    a[v][p] = (k == 1 ? e - s : 0);
    lazy[v][p] = k;
    return;
  }
  int mid = (s + e) / 2;
  shift(v, s, e, p);
  upd(2 * v, s, mid, qs, qe, p, k);
  upd(2 * v + 1, mid, e, qs, qe, p, k);
  a[v][p] = a[2 * v][p] + a[2 * v + 1][p];
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m >> se;
  for (int i = 0; i < n; i++) upd(1, 0, n, i, i + 1, se[i] - 'a', 1);
  for (int z = 0; z < m; z++) {
    int l, r, k;
    cin >> l >> r >> k;
    l--;
    int st = l;
    if (k == 1) {
      for (int j = 0; j < 26; j++) {
        int num = get(1, 0, n, l, r, j);
        upd(1, 0, n, l, r, j, -1);
        upd(1, 0, n, st, st + num, j, 1);
        st += num;
      }
    } else {
      for (int j = 25; j >= 0; j--) {
        int num = get(1, 0, n, l, r, j);
        upd(1, 0, n, l, r, j, -1);
        upd(1, 0, n, st, st + num, j, 1);
        st += num;
      }
    }
  }
  string t = "";
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 26; j++) {
      if (get(1, 0, n, i, i + 1, j) == 1) {
        t += j + 'a';
        break;
      }
    }
  cout << t << endl;
  return 0;
}