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>
const int MaxN = 1e5 + 10;
struct node {
  int l, r;
  int sum, tag;
};
int n, m, a[MaxN];
char s[MaxN], ans[MaxN];
struct SegmentTree {
  node t[MaxN << 2];
  void pushup(int id) { t[id].sum = t[id << 1].sum + t[id << 1 | 1].sum; }
  void build(int id, int l, int r, int val) {
    t[id].l = l, t[id].r = r, t[id].tag = -1;
    if (l == r) {
      if (val == a[l]) t[id].sum = 1;
      return;
    }
    int mid = (l + r) >> 1;
    build(id << 1, l, mid, val), build(id << 1 | 1, mid + 1, r, val),
        pushup(id);
  }
  void pushdown(int id) {
    if (~t[id].tag) {
      int tag = t[id].tag;
      t[id << 1].tag = t[id << 1 | 1].tag = tag, t[id].tag = -1;
      t[id << 1].sum = tag * (t[id << 1].r - t[id << 1].l + 1);
      t[id << 1 | 1].sum = tag * (t[id << 1 | 1].r - t[id << 1 | 1].l + 1);
    }
  }
  void modify(int id, int l, int r, int val) {
    if (t[id].l > r || l > t[id].r) return;
    if (l <= t[id].l && t[id].r <= r) {
      t[id].tag = val, t[id].sum = val * (t[id].r - t[id].l + 1);
      return;
    }
    pushdown(id), modify(id << 1, l, r, val);
    modify(id << 1 | 1, l, r, val), pushup(id);
  }
  int query(int id, int l, int r) {
    if (t[id].l > r || l > t[id].r) return 0;
    if (l <= t[id].l && t[id].r <= r) return t[id].sum;
    pushdown(id);
    return query(id << 1, l, r) + query(id << 1 | 1, l, r);
  }
} T[27];
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') ch = getchar();
  while (ch <= '9' && ch >= '0')
    x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return x;
}
int main() {
  scanf("%d%d%s", &n, &m, s + 1);
  for (int i = 1; i <= n; i++) a[i] = s[i] - 'a' + 1;
  for (int i = 1; i <= 26; i++) T[i].build(1, 1, n, i);
  while (m--) {
    int l = read(), r = read(), op = read();
    if (op == 1) {
      int cnt[27] = {};
      for (int i = 1; i <= 26; i++)
        cnt[i] = T[i].query(1, l, r), T[i].modify(1, l, r, 0);
      int now = l;
      for (int i = 1; i <= 26; i++) {
        if (cnt[i]) T[i].modify(1, now, now + cnt[i] - 1, 1), now += cnt[i];
      }
    } else {
      int cnt[27] = {};
      for (int i = 26; i; i--)
        cnt[i] = T[i].query(1, l, r), T[i].modify(1, l, r, 0);
      int now = l;
      for (int i = 26; i; i--) {
        if (cnt[i]) T[i].modify(1, now, now + cnt[i] - 1, 1), now += cnt[i];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 26; j++) {
      if (T[j].query(1, i, i)) {
        putchar(j + 'a' - 1);
        break;
      }
    }
  }
  return 0;
}