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>
char str[100004];
int cnt[200000][26], tag[200000], ls[200000], rs[200000], segcnt;
void build(int &t, int l, int r) {
  t = segcnt++;
  if (l < r) {
    int mid = (l + r) >> 1, i;
    tag[t] = -1;
    build(ls[t], l, mid), build(rs[t], mid + 1, r);
    for (i = 0; i < 26; i++) cnt[t][i] = cnt[ls[t]][i] + cnt[rs[t]][i];
  } else
    tag[t] = str[l] - 'a', cnt[t][tag[t]] = 1;
}
inline void pushdown(int t, int l, int r) {
  if (ls[t] && tag[t] >= 0) {
    int mid = (l + r) >> 1, i;
    for (i = 0; i < 26; i++) cnt[ls[t]][i] = cnt[rs[t]][i] = 0;
    cnt[ls[t]][tag[t]] = mid - l + 1;
    cnt[rs[t]][tag[t]] = r - mid;
    tag[ls[t]] = tag[rs[t]] = tag[t];
    tag[t] = -1;
  }
}
void query(int t, int l, int r, int _l, int _r, int *res) {
  int mid = (l + r) >> 1, i, c[26];
  if (_l == l && _r == r) {
    for (i = 0; i < 26; i++) res[i] += cnt[t][i];
    return;
  }
  pushdown(t, l, r);
  if (_r <= mid)
    query(ls[t], l, mid, _l, _r, res);
  else if (_l > mid)
    query(rs[t], mid + 1, r, _l, _r, res);
  else {
    for (i = 0; i < 26; i++) c[i] = 0;
    query(ls[t], l, mid, _l, mid, res);
    query(rs[t], mid + 1, r, mid + 1, _r, c);
    for (i = 0; i < 26; i++) res[i] += c[i];
  }
}
void modify(int t, int l, int r, int _l, int _r, int k) {
  int mid = (l + r) >> 1, i;
  if (_l == l && _r == r) {
    for (i = 0; i < 26; i++) cnt[t][i] = 0;
    cnt[t][k] = r - l + 1, tag[t] = k;
    return;
  }
  pushdown(t, l, r);
  if (_r <= mid)
    modify(ls[t], l, mid, _l, _r, k);
  else if (_l > mid)
    modify(rs[t], mid + 1, r, _l, _r, k);
  else
    modify(ls[t], l, mid, _l, mid, k),
        modify(rs[t], mid + 1, r, mid + 1, _r, k);
  for (i = 0; i < 26; i++) cnt[t][i] = cnt[ls[t]][i] + cnt[rs[t]][i];
}
void dfs(int t, int l, int r) {
  if (l == r)
    putchar(tag[t] + 'a');
  else {
    int mid = (l + r) >> 1;
    pushdown(t, l, r);
    dfs(ls[t], l, mid), dfs(rs[t], mid + 1, r);
  }
}
int main() {
  int N, M, root, l, r, k, i, c[26];
  scanf("%d%d%s", &N, &M, str + 1);
  build(root, 1, N);
  while (M--) {
    scanf("%d%d%d", &l, &r, &k);
    for (i = 0; i < 26; i++) c[i] = 0;
    query(root, 1, N, l, r, c), r = 0;
    if (k == 1) {
      for (i = 0; i < 26; i++)
        if (c[i]) modify(root, 1, N, l + r, l + r + c[i] - 1, i), r += c[i];
    } else {
      for (i = 25; i >= 0; i--)
        if (c[i]) modify(root, 1, N, l + r, l + r + c[i] - 1, i), r += c[i];
    }
  }
  dfs(root, 1, N);
  return 0;
}