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;
struct node {
  int lazy;
  int cnt[26];
};
node tree[(1 << 19)];
void insert_element(int l, int r, int e, int p = 1, int st = 1,
                    int ed = 100001) {
  if (st == ed) {
    tree[p].lazy = 0;
    memset(tree[p].cnt, 0, sizeof(tree[p].cnt));
    tree[p].cnt[e]++;
    return;
  }
  if (st >= l && ed <= r) {
    tree[p].lazy = 1;
    memset(tree[p].cnt, 0, sizeof(tree[p].cnt));
    tree[p].cnt[e] = ed - st + 1;
    return;
  }
  int mid = (st + ed) / 2;
  if (tree[p].lazy) {
    for (int i = 0; i < 26; i++) {
      if (tree[p].cnt[i]) {
        tree[p * 2].cnt[i] = mid - st + 1;
        tree[p * 2 + 1].cnt[i] = ed - mid;
      } else {
        tree[p * 2].cnt[i] = tree[p * 2 + 1].cnt[i] = 0;
      }
    }
    tree[p * 2].lazy = tree[p * 2 + 1].lazy = 1;
  }
  if (l <= mid) {
    insert_element(l, r, e, p * 2, st, mid);
  }
  if (r > mid) {
    insert_element(l, r, e, p * 2 + 1, mid + 1, ed);
  }
  for (int i = 0; !tree[p].lazy && i < 26; i++) {
    tree[p].cnt[i] = tree[p * 2].cnt[i] + tree[p * 2 + 1].cnt[i];
  }
  tree[p].lazy = 0;
}
int get_element(int l, int r, int e, int p = 1, int st = 1, int ed = 100001) {
  if (st == ed) {
    return tree[p].cnt[e];
  }
  if (st >= l && ed <= r) {
    return tree[p].cnt[e];
  }
  int mid = (st + ed) / 2;
  if (tree[p].lazy) {
    for (int i = 0; i < 26; i++) {
      if (tree[p].cnt[i]) {
        tree[p * 2].cnt[i] = mid - st + 1;
        tree[p * 2 + 1].cnt[i] = ed - mid;
      } else {
        tree[p * 2].cnt[i] = tree[p * 2 + 1].cnt[i] = 0;
      }
    }
    tree[p * 2].lazy = tree[p * 2 + 1].lazy = 1;
  }
  int sum = 0;
  if (l <= mid) {
    sum += get_element(l, r, e, p * 2, st, mid);
  }
  if (r > mid) {
    sum += get_element(l, r, e, p * 2 + 1, mid + 1, ed);
  }
  for (int i = 0; !tree[p].lazy && i < 26; i++) {
    tree[p].cnt[i] = tree[p * 2].cnt[i] + tree[p * 2 + 1].cnt[i];
  }
  tree[p].lazy = 0;
  return sum;
}
char s[100001];
int cnt[26];
int main() {
  int n, q;
  int l, r, k;
  scanf("%d%d", &n, &q);
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    insert_element(i + 1, i + 1, s[i] - 'a');
  }
  while (q--) {
    scanf("%d%d%d", &l, &r, &k);
    for (int i = 0; i < 26; i++) {
      cnt[i] = get_element(l, r, i);
    }
    if (k) {
      for (int i = 0; i < 26; i++) {
        if (cnt[i]) {
          insert_element(l, l + cnt[i] - 1, i);
          l += cnt[i];
        }
      }
    } else {
      for (int i = 25; i >= 0; i--) {
        if (cnt[i]) {
          insert_element(l, l + cnt[i] - 1, i);
          l += cnt[i];
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 26; j++) {
      if (get_element(i, i, j)) putchar((char)j + 'a');
    }
  }
}