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;
char str[100005];
int seg[26][400005], lazy[26][400005];
void propagate(int n, int let, int s, int e) {
  int mid = (s + e) >> 1;
  lazy[let][n * 2] = lazy[let][n];
  lazy[let][n * 2 + 1] = lazy[let][n];
  seg[let][n * 2] = (mid - s + 1) * ((lazy[let][n]) % 2);
  seg[let][n * 2 + 1] = (e - mid) * ((lazy[let][n]) % 2);
  lazy[let][n] = 0;
  return;
}
void update(int n, int s, int e, int l, int r, int let, int val) {
  if (s >= l && e <= r) {
    lazy[let][n] = val;
    seg[let][n] = (e - s + 1) * (val % 2);
    return;
  }
  if (s > r || e < l) return;
  if (lazy[let][n]) propagate(n, let, s, e);
  int mid = (s + e) >> 1;
  update(n * 2, s, mid, l, r, let, val);
  update(n * 2 + 1, mid + 1, e, l, r, let, val);
  seg[let][n] = seg[let][n * 2] + seg[let][n * 2 + 1];
  return;
}
int query(int n, int s, int e, int l, int r, int let) {
  if (s >= l && e <= r) return seg[let][n];
  if (s > r || e < l) return 0;
  if (lazy[let][n]) propagate(n, let, s, e);
  int mid = (s + e) >> 1;
  return (query(n * 2, s, mid, l, r, let) +
          query(n * 2 + 1, mid + 1, e, l, r, let));
}
int main() {
  int n, q, l, r, k, c[26];
  scanf("%d %d %s", &n, &q, str);
  for (int i = 0; i < n; i++) update(1, 1, n, i + 1, i + 1, str[i] - 'a', 1);
  while (q--) {
    scanf("%d %d %d", &l, &r, &k);
    if (k) {
      for (int i = 0; i < 26; i++) {
        c[i] = query(1, 1, n, l, r, i);
        if (c[i]) update(1, 1, n, l, r, i, 2);
      }
      for (int i = 0; i < 26; i++)
        if (c[i]) update(1, 1, n, l, l + c[i] - 1, i, 1), l += c[i];
    } else {
      for (int i = 25; i >= 0; i--) {
        c[i] = query(1, 1, n, l, r, i);
        if (c[i]) update(1, 1, n, l, r, i, 2);
      }
      for (int i = 25; i >= 0; i--)
        if (c[i]) update(1, 1, n, l, l + c[i] - 1, i, 1), l += c[i];
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 26; j++)
      if (query(1, 1, n, i + 1, i + 1, j)) {
        str[i] = 'a' + j;
        break;
      }
  printf("%s\n", str);
  return 0;
}