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 N = 100 * 1000 + 20;
int n, q;
string s;
int seg[N << 2][50], lz[N << 2][50];
void build(int id = 1, int l = 1, int r = n) {
  if (l == r) {
    seg[id][s[l - 1] - 'a'] = 1;
    return;
  }
  int mid = l + r >> 1;
  build(id << 1, l, mid);
  build(id << 1 | 1, mid + 1, r);
  for (int i = 0; i < 26; i++)
    seg[id][i] = seg[id << 1][i] + seg[id << 1 | 1][i];
}
void shift(int id, int l, int r, int c) {
  seg[id][c] = lz[id][c] * (r - l + 1);
  if (l ^ r) lz[id << 1][c] = lz[id][c], lz[id << 1 | 1][c] = lz[id][c];
  lz[id][c] = -1;
  return;
}
void upd(int lq, int rq, int c, int val, int id = 1, int l = 1, int r = n) {
  if (lz[id][c] != -1) shift(id, l, r, c);
  if (lq > r || rq < l) return;
  if (l >= lq && r <= rq) {
    lz[id][c] = val;
    shift(id, l, r, c);
    return;
  }
  int mid = l + r >> 1;
  upd(lq, rq, c, val, id << 1, l, mid);
  upd(lq, rq, c, val, id << 1 | 1, mid + 1, r);
  seg[id][c] = seg[id << 1][c] + seg[id << 1 | 1][c];
}
int get(int lq, int rq, int c, int id = 1, int l = 1, int r = n) {
  if (lz[id][c] != -1) shift(id, l, r, c);
  if (lq > r || l > rq) return 0;
  if (l >= lq && r <= rq) return seg[id][c];
  int mid = l + r >> 1;
  return get(lq, rq, c, id << 1, l, mid) +
         get(lq, rq, c, id << 1 | 1, mid + 1, r);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  memset(lz, -1, sizeof lz);
  cin >> n >> q >> s;
  build();
  while (q--) {
    int lq, rq, val;
    cin >> lq >> rq >> val;
    if (!val) {
      int T = lq;
      for (int i = 25; ~i; i--) {
        int cnt = get(lq, rq, i);
        upd(lq, rq, i, 0);
        if (cnt) upd(T, T + cnt - 1, i, 1);
        T += cnt;
      }
    } else {
      int T = lq;
      for (int i = 0; i < 26; i++) {
        int cnt = get(lq, rq, i);
        upd(lq, rq, i, 0);
        if (cnt) upd(T, T + cnt - 1, i, 1);
        T += cnt;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 26; j++)
      if (get(i, i, j)) cout << (char)(j + 'a');
  cout << endl;
  return 0;
}