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, hav[26];
string str;
struct Tree {
  int l, r, sum, lazy;
};
struct segmenttree {
  Tree tree[100010 << 2];
  void push_down(int u) {
    int lazy = tree[u].lazy;
    if (lazy != -1) {
      tree[u << 1].lazy = tree[u << 1 | 1].lazy = lazy;
      tree[u << 1].sum = (tree[u << 1].r - tree[u << 1].l + 1) * lazy;
      tree[u << 1 | 1].sum =
          (tree[u << 1 | 1].r - tree[u << 1 | 1].l + 1) * lazy;
      tree[u].lazy = -1;
    }
  }
  void build(int p, int l, int r, int num) {
    tree[p].l = l;
    tree[p].r = r;
    tree[p].lazy = -1;
    if (l == r) {
      int num1 = str[l] - 'a';
      if (num == num1) {
        tree[p].sum = 1;
      } else {
        tree[p].sum = 0;
      }
      return;
    }
    int mid = (l + r) / 2;
    build(p * 2, l, mid, num);
    build(p * 2 + 1, mid + 1, r, num);
    tree[p].sum = tree[p * 2].sum + tree[p * 2 + 1].sum;
  }
  int ask(int p, int l, int r) {
    if (l <= tree[p].l && r >= tree[p].r) {
      return tree[p].sum;
    }
    int res = 0;
    int mid = (tree[p].l + tree[p].r) / 2;
    push_down(p);
    if (l <= mid) {
      res += ask(p * 2, l, r);
    }
    if (r > mid) {
      res += ask(p * 2 + 1, l, r);
    }
    return res;
  }
  void update(int p, int l, int r, int v) {
    if (l <= tree[p].l && r >= tree[p].r) {
      tree[p].sum = (tree[p].r - tree[p].l + 1) * v;
      tree[p].lazy = v;
      return;
    }
    int mid = (tree[p].l + tree[p].r) / 2;
    push_down(p);
    if (l <= mid) {
      update(p << 1, l, r, v);
    }
    if (r > mid) {
      update(p << 1 | 1, l, r, v);
    }
    tree[p].sum = tree[p << 1].sum + tree[p << 1 | 1].sum;
  }
} tra[26];
int main() {
  scanf("%d%d", &n, &q);
  cin >> str;
  for (int i = 0; i < 26; i++) {
    tra[i].build(1, 0, n - 1, i);
  }
  while (q--) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    x--, y--;
    for (int i = 0; i < 26; i++) {
      hav[i] = tra[i].ask(1, x, y);
      tra[i].update(1, x, y, 0);
    }
    int l = x;
    if (z) {
      for (int i = 0; i < 26; i++) {
        if (hav[i]) {
          tra[i].update(1, l, l + hav[i] - 1, 1);
          l += hav[i];
        }
      }
    } else {
      for (int i = 25; i >= 0; i--) {
        if (hav[i]) {
          tra[i].update(1, l, l + hav[i] - 1, 1);
          l += hav[i];
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      if (tra[j].ask(1, i, i)) {
        printf("%c", j + 'a');
        break;
      }
    }
  }
  printf("\n");
  return 0;
}