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 INF = 2147483647;
const int N = 1e5 + 10;
struct Segment_Tree {
  struct Tree {
    int l, r;
    int sum, tag;
  } tr[N * 4];
  void push_up(int x) { tr[x].sum = tr[x << 1].sum + tr[x << 1 | 1].sum; }
  void push_down(int x) {
    int l = x << 1, r = x << 1 | 1, tag = tr[x].tag;
    if (tag == -1) return;
    tr[l].sum = tag * (tr[l].r - tr[l].l + 1);
    tr[l].tag = tag;
    tr[r].sum = tag * (tr[r].r - tr[r].l + 1);
    tr[r].tag = tag;
    tr[x].tag = -1;
  }
  void build(int x, int l, int r) {
    tr[x] = (Tree){l, r, 0, 0};
    if (l == r) return;
    int mid = (l + r) / 2;
    if (l <= mid) build(x << 1, l, mid);
    if (mid < r) build(x << 1 | 1, mid + 1, r);
    push_up(x);
  }
  void add(int x, int l, int r, int k) {
    if (l <= tr[x].l && tr[x].r <= r) {
      tr[x].sum = k * (tr[x].r - tr[x].l + 1);
      tr[x].tag = k;
      return;
    }
    push_down(x);
    int mid = (tr[x].l + tr[x].r) / 2;
    if (l <= mid) add(x << 1, l, r, k);
    if (mid < r) add(x << 1 | 1, l, r, k);
    push_up(x);
  }
  int sum(int x, int l, int r) {
    if (l <= tr[x].l && tr[x].r <= r) return tr[x].sum;
    push_down(x);
    int mid = (tr[x].l + tr[x].r) / 2, Sum = 0;
    if (l <= mid) Sum += sum(x << 1, l, r);
    if (mid < r) Sum += sum(x << 1 | 1, l, r);
    return Sum;
  }
} tr[26];
void ans(int x, int l, int r) {
  if (l == r) {
    for (int i = 0; i < 26; i++) {
      if (tr[i].tr[x].sum == 0) continue;
      cout << (char)('a' + i);
      return;
    }
  }
  for (int i = 0; i < 26; i++) {
    tr[i].push_down(x);
  }
  int mid = (l + r) / 2;
  if (l <= mid) ans(x << 1, l, mid);
  if (mid < r) ans(x << 1 | 1, mid + 1, r);
}
int n, q;
int main() {
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 0; i < 26; i++) {
    tr[i].build(1, 1, n);
  }
  for (int i = 1; i <= n; i++) {
    char x;
    cin >> x;
    tr[x - 'a'].add(1, i, i, 1);
  }
  while (q--) {
    int op, x, y;
    cin >> x >> y >> op;
    if (op == 1) {
      int sum, cnt = x;
      for (int i = 0; i < 26; i++) {
        sum = tr[i].sum(1, x, y);
        if (sum == 0) continue;
        tr[i].add(1, x, y, 0);
        tr[i].add(1, cnt, cnt + sum - 1, 1);
        cnt += sum;
      }
    }
    if (op == 0) {
      int sum, cnt = x;
      for (int i = 25; i >= 0; i--) {
        sum = tr[i].sum(1, x, y);
        if (sum == 0) continue;
        tr[i].add(1, x, y, 0);
        tr[i].add(1, cnt, cnt + sum - 1, 1);
        cnt += sum;
      }
    }
  }
  ans(1, 1, n);
  return 0;
}