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 MAXN = 1e5 + 10;
struct Tree {
  int l, r, lazy, sum;
};
char str[MAXN];
struct Segment_tree {
  Tree tree[MAXN << 2];
  void pushup(int root) {
    tree[root].sum = tree[root << 1].sum + tree[root << 1 | 1].sum;
  }
  void pushdown(int root) {
    if (~tree[root].lazy) {
      tree[root << 1 | 1].lazy = tree[root << 1].lazy = tree[root].lazy;
      tree[root << 1].sum =
          (tree[root << 1].r - tree[root << 1].l) * tree[root].lazy;
      tree[root << 1 | 1].sum =
          (tree[root << 1 | 1].r - tree[root << 1 | 1].l) * tree[root].lazy;
      tree[root].lazy = -1;
    }
  }
  void build(int k, int l, int r, int val) {
    tree[k].l = l, tree[k].r = r;
    tree[k].lazy = -1;
    if (r - l == 1) {
      if (str[l] - 'a' == val)
        tree[k].sum = 1;
      else
        tree[k].sum = 0;
    } else {
      build(k << 1, l, l + (r - l) / 2, val);
      build(k << 1 | 1, l + (r - l) / 2, r, val);
      pushup(k);
    }
  }
  void update(int k, int ql, int qr, int val) {
    int &l = tree[k].l, &r = tree[k].r;
    if (l >= ql && r <= qr) {
      tree[k].lazy = val;
      tree[k].sum = (r - l) * val;
    } else if (l < qr && r > ql) {
      pushdown(k);
      update(k << 1, ql, qr, val);
      update(k << 1 | 1, ql, qr, val);
      pushup(k);
    }
  }
  int query(int k, int ql, int qr) {
    int &l = tree[k].l, &r = tree[k].r;
    if (l >= ql && r <= qr)
      return tree[k].sum;
    else if (l < qr && r > ql) {
      pushdown(k);
      return query(k << 1, ql, qr) + query(k << 1 | 1, ql, qr);
    }
    return 0;
  }
} alpha[26];
int record[26];
void solve() {
  int n, q, a, b, c;
  scanf("%d%d", &n, &q);
  scanf("%s", str);
  for (int i = 0; i < 26; ++i) alpha[i].build(1, 0, n, i);
  for (int i = 0; i < q; ++i) {
    memset(record, 0, sizeof(record));
    scanf("%d%d%d", &a, &b, &c);
    --a;
    for (int i = 0; i < 26; ++i) {
      record[i] = alpha[i].query(1, a, b);
      alpha[i].update(1, a, b, 0);
    }
    if (c) {
      for (int i = 0; i < 26; a += record[i], ++i)
        if (record[i]) alpha[i].update(1, a, a + record[i], 1);
    } else {
      for (int i = 25; i >= 0; a += record[i], --i)
        if (record[i]) alpha[i].update(1, a, a + record[i], 1);
    }
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j) {
      if (alpha[j].query(1, i, i + 1)) {
        printf("%c", 'a' + j);
        break;
      }
    }
}
int main(void) { solve(); }