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 s[100005];
int tree[400005][26], lazy[400005][26];
int cnt[26];
void build(int i, int L, int R) {
  if (L == R) {
    tree[i][s[L] - 'a'] = 1;
    for (int j = 0; j < 26; ++j) lazy[i][j] = -1;
    return;
  }
  build(i * 2 + 1, L, (L + R) / 2);
  build(i * 2 + 2, (L + R) / 2 + 1, R);
  for (int j = 0; j < 26; ++j) {
    lazy[i][j] = -1;
    tree[i][j] = tree[i * 2 + 1][j] + tree[i * 2 + 2][j];
  }
  return;
}
int query(int i, int x, int y, int L, int R, int j) {
  if (lazy[i][j] != -1) {
    tree[i][j] = lazy[i][j] * (R - L + 1);
    if (L != R) {
      lazy[i * 2 + 1][j] = lazy[i][j];
      lazy[i * 2 + 2][j] = lazy[i][j];
    }
    lazy[i][j] = -1;
  }
  if (L >= x && R <= y) return tree[i][j];
  if (L > y || x > R) return 0;
  return query(i * 2 + 1, x, y, L, (L + R) / 2, j) +
         query(i * 2 + 2, x, y, (L + R) / 2 + 1, R, j);
}
void update(int i, int x, int y, int L, int R, int val, int j) {
  if (lazy[i][j] != -1) {
    tree[i][j] = lazy[i][j] * (R - L + 1);
    if (L != R) {
      lazy[i * 2 + 1][j] = lazy[i][j];
      lazy[i * 2 + 2][j] = lazy[i][j];
    }
    lazy[i][j] = -1;
  }
  if (L >= x && R <= y) {
    lazy[i][j] = val;
    tree[i][j] = lazy[i][j] * (R - L + 1);
    if (L != R) {
      lazy[i * 2 + 1][j] = lazy[i][j];
      lazy[i * 2 + 2][j] = lazy[i][j];
    }
    lazy[i][j] = -1;
    return;
  }
  if (L > y || R < x) return;
  update(i * 2 + 1, x, y, L, (L + R) / 2, val, j);
  update(i * 2 + 2, x, y, (L + R) / 2 + 1, R, val, j);
  tree[i][j] = tree[i * 2 + 1][j] + tree[i * 2 + 2][j];
}
void get(int i, int L, int R, int j) {
  if (lazy[i][j] != -1) {
    tree[i][j] = lazy[i][j] * (R - L + 1);
    if (L != R) {
      lazy[i * 2 + 1][j] = lazy[i][j];
      lazy[i * 2 + 2][j] = lazy[i][j];
    }
    lazy[i][j] = -1;
  }
  if (!tree[i][j]) return;
  if (L == R) {
    s[L] = j + 'a';
    return;
  }
  get(i * 2 + 1, L, (L + R) / 2, j);
  get(i * 2 + 2, (L + R) / 2 + 1, R, j);
}
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  scanf("%s", s);
  build(0, 0, n - 1);
  int x, y, up;
  for (int i = 0; i < q; ++i) {
    scanf("%d %d %d", &x, &y, &up);
    --x, --y;
    for (int j = 0; j < 26; ++j) cnt[j] = query(0, x, y, 0, n - 1, j);
    int cur = x;
    if (!up) cur = y;
    for (int j = 0; j < 26; ++j) {
      if (!cnt[j]) continue;
      update(0, x, y, 0, n - 1, 0, j);
      if (up) {
        update(0, cur, cur + cnt[j] - 1, 0, n - 1, 1, j);
        cur += cnt[j];
      } else {
        update(0, cur - cnt[j] + 1, cur, 0, n - 1, 1, j);
        cur -= cnt[j];
      }
    }
  }
  for (int i = 0; i < 26; i++) get(0, 0, n - 1, i);
  printf("%s\n", s);
  return 0;
}