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;
int sum[27][300000];
int len, q;
int limit;
int ans[666660];
int flag[27][300000];
void pushDown(int a, int x, int ll, int rr) {
  int mid = ll + rr >> 1;
  if (flag[a][x] != -1) {
    sum[a][x << 1] = (mid - ll + 1) * flag[a][x];
    sum[a][x << 1 | 1] = (rr - mid) * flag[a][x];
    flag[a][x << 1] = flag[a][x];
    flag[a][x << 1 | 1] = flag[a][x];
    flag[a][x] = -1;
  }
}
void update(int a, int x, int ls, int rs) {
  sum[a][x] = sum[a][ls] + sum[a][rs];
}
void insert(int a, int x, int ll, int rr, int l, int r, int d) {
  int ls = x << 1, rs = ls | 1, mid = ll + rr >> 1;
  if (l == ll && rr == r) {
    sum[a][x] = d * (rr - ll + 1);
    flag[a][x] = d;
    return;
  }
  pushDown(a, x, ll, rr);
  if (r <= mid)
    insert(a, ls, ll, mid, l, r, d);
  else if (l > mid)
    insert(a, rs, mid + 1, rr, l, r, d);
  else {
    insert(a, ls, ll, mid, l, mid, d);
    insert(a, rs, mid + 1, rr, mid + 1, r, d);
  }
  update(a, x, ls, rs);
}
int quary(int a, int x, int ll, int rr, int l, int r) {
  int ls = x << 1, rs = ls | 1, mid = ll + rr >> 1;
  if (l == ll && rr == r) {
    return sum[a][x];
  }
  pushDown(a, x, ll, rr);
  int ans;
  if (r <= mid)
    ans = quary(a, ls, ll, mid, l, r);
  else if (l > mid)
    ans = quary(a, rs, mid + 1, rr, l, r);
  else {
    ans = quary(a, ls, ll, mid, l, mid) + quary(a, rs, mid + 1, rr, mid + 1, r);
  }
  update(a, x, ls, rs);
  return ans;
}
void printStr() {
  for (int i = 1; i <= len; i++)
    for (int j = 1; j <= 26; j++) {
      if (quary(j, 1, 1, limit, i, i)) {
        ans[i] = j;
      }
    }
  for (int i = 1; i <= len; i++) printf("%c", ans[i] + 'a' - 1);
  puts("");
}
int main() {
  scanf("%d%d", &len, &q);
  getchar();
  limit = 1;
  memset(flag, -1, sizeof(-1));
  while (limit < len) limit <<= 1;
  for (int i = 1; i <= len; i++) {
    int a = getchar() - 'a' + 1;
    insert(a, 1, 1, limit, i, i, 1);
  }
  for (int i = 1; i <= q; i++) {
    int l, r, c;
    scanf("%d%d%d", &l, &r, &c);
    int now = 0;
    if (c == 0) {
      for (int j = 1; j <= 26; j++) {
        int cnt = quary(j, 1, 1, limit, l, r);
        if (cnt == 0) continue;
        insert(j, 1, 1, limit, l, r, 0);
        insert(j, 1, 1, limit, r - now - cnt + 1, r - now, 1);
        now += cnt;
      }
    } else {
      for (int j = 1; j <= 26; j++) {
        int cnt = quary(j, 1, 1, limit, l, r);
        if (cnt == 0) continue;
        insert(j, 1, 1, limit, l, r, 0);
        insert(j, 1, 1, limit, l + now, l + now + cnt - 1, 1);
        now += cnt;
      }
    }
  }
  printStr();
}