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 = 222222;
int n, m;
int tag[26][MAXN * 4], T[26][MAXN * 4];
void update(int id, int x, int range) {
  if (tag[id][x] > -1) {
    T[id][x] = tag[id][x] * range;
    if (range > 1) {
      tag[id][(x << 1)] = tag[id][x];
      tag[id][(((x << 1)) + 1)] = tag[id][x];
    }
    tag[id][x] = -1;
  }
}
void seg_clear(int id, int x, int l, int r, int ql, int qr) {
  update(id, x, r - l + 1);
  if (ql <= l && qr >= r) {
    tag[id][x] = 0;
    update(id, x, r - l + 1);
    return;
  } else {
    int mid = (l + r) >> 1;
    if (ql <= mid) seg_clear(id, (x << 1), l, mid, ql, qr);
    if (qr > mid) seg_clear(id, (((x << 1)) + 1), mid + 1, r, ql, qr);
    if (r > l) {
      update(id, (x << 1), mid - l + 1);
      update(id, (((x << 1)) + 1), r - mid);
      T[id][x] = T[id][(x << 1)] + T[id][(((x << 1)) + 1)];
    }
  }
}
int seg_calc(int id, int x, int l, int r, int ql, int qr) {
  update(id, x, r - l + 1);
  if (ql <= l && qr >= r) {
    return T[id][x];
  } else {
    int mid = (l + r) >> 1, ret = 0;
    if (ql <= mid) ret += seg_calc(id, (x << 1), l, mid, ql, qr);
    if (qr > mid) ret += seg_calc(id, (((x << 1)) + 1), mid + 1, r, ql, qr);
    if (r > l) {
      update(id, (x << 1), mid - l + 1);
      update(id, (((x << 1)) + 1), r - mid);
      T[id][x] = T[id][(x << 1)] + T[id][(((x << 1)) + 1)];
    }
    return ret;
  }
}
void seg_add(int id, int x, int l, int r, int ql, int qr) {
  update(id, x, r - l + 1);
  if (ql <= l && qr >= r) {
    tag[id][x] = 1;
    update(id, x, r - l + 1);
  } else {
    int mid = (l + r) >> 1;
    if (ql <= mid) seg_add(id, (x << 1), l, mid, ql, qr);
    if (qr > mid) seg_add(id, (((x << 1)) + 1), mid + 1, r, ql, qr);
    if (r > l) {
      update(id, (x << 1), mid - l + 1);
      update(id, (((x << 1)) + 1), r - mid);
      T[id][x] = T[id][(x << 1)] + T[id][(((x << 1)) + 1)];
    }
  }
}
char ans[MAXN];
int main() {
  scanf("%d%d", &n, &m);
  char str[MAXN];
  scanf("%s", str + 1);
  memset(tag, -1, sizeof tag);
  for (int i = 1; i <= n; i++) seg_add(str[i] - 'a', 1, 1, n, i, i);
  for (int i = 1; i <= m; i++) {
    int ql, qr, flg;
    scanf("%d%d%d", &ql, &qr, &flg);
    if (flg == 1) {
      int now = ql;
      for (int ch = 0; ch <= 25; ch++) {
        int range = seg_calc(ch, 1, 1, n, ql, qr);
        if (range) {
          seg_clear(ch, 1, 1, n, ql, qr);
          seg_add(ch, 1, 1, n, now, now + range - 1);
          now += range;
        }
      }
    } else {
      int now = ql;
      for (int ch = 25; ch >= 0; ch--) {
        int range = seg_calc(ch, 1, 1, n, ql, qr);
        if (range) {
          seg_clear(ch, 1, 1, n, ql, qr);
          seg_add(ch, 1, 1, n, now, now + range - 1);
          now += range;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 25; j++)
      if (seg_calc(j, 1, 1, n, i, i)) {
        ans[i] = j + 'a';
        break;
      }
  for (int i = 1; i <= n; i++) putchar(ans[i]);
  puts("");
  return 0;
}