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;
int n, q;
string s;
int st[26][4 * 100005];
int lz[26][4 * 100005];
void init() {
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 4 * 100005; j++) {
      st[i][j] = 0;
      lz[i][j] = 0;
    }
  }
  return;
}
void upd_node(int stidx, int l, int r, int idx) {
  if (lz[stidx][idx]) {
    if (lz[stidx][idx] == 1)
      st[stidx][idx] = (r - l + 1);
    else
      st[stidx][idx] = 0;
    if (l != r)
      lz[stidx][2 * idx + 1] = lz[stidx][2 * idx + 2] = lz[stidx][idx];
    lz[stidx][idx] = 0;
  }
  return;
}
void update(int stidx, int x, int y, int val, int l = 0, int r = n - 1,
            int idx = 0) {
  if (l <= r) upd_node(stidx, l, r, idx);
  if (y < l || x > r) {
    return;
  } else if (x <= l && r <= y) {
    lz[stidx][idx] = val;
    upd_node(stidx, l, r, idx);
    return;
  }
  upd_node(stidx, l, r, idx);
  int mid = l + (r - l) / 2;
  update(stidx, x, y, val, l, mid, 2 * idx + 1);
  update(stidx, x, y, val, mid + 1, r, 2 * idx + 2);
  st[stidx][idx] = st[stidx][2 * idx + 1] + st[stidx][2 * idx + 2];
  return;
}
int query(int stidx, int x, int y, int l = 0, int r = n - 1, int idx = 0) {
  if (l <= r) upd_node(stidx, l, r, idx);
  if (y < l || x > r) {
    return 0;
  } else if (x <= l && y >= r) {
    return st[stidx][idx];
  }
  upd_node(stidx, l, r, idx);
  int mid = l + (r - l) / 2;
  return query(stidx, x, y, l, mid, 2 * idx + 1) +
         query(stidx, x, y, mid + 1, r, 2 * idx + 2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  init();
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < n; i++) {
    update((int)(s[i] - 'a'), i, i, 1);
  }
  int i, j, k;
  while (q--) {
    cin >> i >> j >> k;
    i--;
    j--;
    int lo = i, hi;
    if (k == 1) {
      for (int stidx = 0; stidx < 26; stidx++) {
        hi = query(stidx, i, j) + lo - 1;
        if (hi >= lo) {
          update(stidx, i, j, 2);
          update(stidx, lo, hi, 1);
          lo = hi + 1;
        }
      }
    } else {
      for (int stidx = 25; stidx >= 0; stidx--) {
        hi = query(stidx, i, j) + lo - 1;
        if (hi >= lo) {
          update(stidx, i, j, 2);
          update(stidx, lo, hi, 1);
          lo = hi + 1;
        }
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < n; j++) {
      if (query(i, j, j)) s[j] = (char)(i + 'a');
    }
  }
  cout << s << endl;
  return 0;
}