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 N = 1e5 + 10;
int lft, rght, n, n2, sz, p, p2, tmp, q, k, cnt[30], c[330][30], t[330], a[N];
char ch;
void cntSort(int lft, int rght) {
  int c[30];
  for (int x = 0; x < 26; x++) c[x] = 0;
  for (int i = lft; i <= rght; i++) {
    c[a[i]]++;
  }
  for (int i = lft, x = 25; x >= 0; x--) {
    for (; c[x] > 0; c[x]--, i++) {
      a[i] = x;
    }
  }
}
void cntSort2(int lft, int rght) {
  int c[30];
  for (int x = 0; x < 26; x++) c[x] = 0;
  for (int i = lft; i <= rght; i++) {
    c[a[i]]++;
  }
  for (int i = lft, x = 0; x < 26; x++) {
    for (; c[x] > 0; c[x]--, i++) {
      a[i] = x;
    }
  }
}
void f(int p) {
  for (int j = 0, x = sz * p; j < 26; j++) {
    for (int y = c[p][j]; y > 0; x++, y--) {
      a[x] = j;
    }
  }
  t[p] = 0;
}
void f2(int p) {
  for (int j = 25, x = sz * p; j >= 0; j--) {
    for (int y = c[p][j]; y > 0; x++, y--) {
      a[x] = j;
    }
  }
  t[p] = 0;
}
void f3(int frst, int lst, int p) {
  for (int i = frst; i < lst; i++) {
    cnt[a[i]]++;
    c[p][a[i]]--;
  }
}
void f4(int frst, int lst, int p) {
  for (int x = 0, i = frst; x < 26; x++) {
    for (; i < lst && cnt[x] > 0; i++, cnt[x]--) {
      a[i] = x;
      c[p][x]++;
    }
  }
}
void f5(int j, int x) {
  if (cnt[x] > tmp) {
    c[j][x] = tmp;
    cnt[x] -= tmp;
    tmp = 0;
  } else {
    c[j][x] = cnt[x];
    tmp -= cnt[x];
    cnt[x] = 0;
  }
}
void f6(int frst, int lst, int p) {
  for (int x = 25, i = frst; x >= 0; x--) {
    for (; i < lst && cnt[x] > 0; i++, cnt[x]--) {
      a[i] = x;
      c[p][x]++;
    }
  }
}
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  sz = sqrtl(n);
  n2 = (n - 1) / sz;
  for (int i = 0; i <= n2; i++) {
    t[i] = 0;
    for (int x = 0; x < 26; x++) c[i][x] = 0;
  }
  for (int i = 0; i < n; i++) {
    cin >> ch;
    a[i] = ch - 'a';
    c[i / sz][a[i]]++;
  }
  for (int i = 1; i <= q; i++) {
    cin >> lft >> rght >> k;
    lft--;
    rght--;
    p = lft / sz;
    p2 = rght / sz;
    if (t[p] == 1)
      f(p);
    else if (t[p] == 2)
      f2(p);
    if (p == p2) {
      if (k == 0)
        cntSort(lft, rght);
      else
        cntSort2(lft, rght);
      continue;
    }
    if (t[p2] == 1)
      f(p2);
    else if (t[p2] == 2)
      f2(p2);
    for (int j = 0; j < 26; j++) cnt[j] = 0;
    f3(lft, sz * (p + 1), p);
    f3(sz * p2, rght + 1, p2);
    for (int j = p + 1; j < p2; j++) {
      for (int x = 0; x < 26; x++) cnt[x] += c[j][x];
    }
    if (k == 1) {
      f4(lft, sz * (p + 1), p);
      for (int j = p + 1; j < p2; j++) {
        if (j == n2)
          tmp = n - (sz * j);
        else
          tmp = sz;
        for (int x = 0; x < 26; x++) {
          f5(j, x);
        }
        t[j] = 1;
      }
      f4(sz * p2, rght + 1, p2);
    } else {
      f6(lft, sz * (p + 1), p);
      for (int j = p + 1; j < p2; j++) {
        if (j == n2)
          tmp = n - (sz * j);
        else
          tmp = sz;
        for (int x = 25; x >= 0; x--) {
          f5(j, x);
        }
        t[j] = 2;
      }
      f6(sz * p2, rght + 1, p2);
    }
  }
  for (int i = 0; i <= n2; i++) {
    if (t[i] == 1)
      f(i);
    else if (t[i] == 2)
      f2(i);
  }
  for (int i = 0; i < n; i++) cout << (char)(a[i] + 'a');
  cout << "\n";
  return 0;
}