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;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
int n, q;
char s[N];
struct seg {
  int l, r, cnt[26], tag[26];
} t[N << 2];
void pushup(int p) {
  for (int i = 0; i < 26; i++)
    t[p].cnt[i] = t[p << 1].cnt[i] + t[p << 1 | 1].cnt[i];
}
void pushdown(int p, int z) {
  int &x = t[p].tag[z];
  int l = t[p].l, r = t[p].r, mid = (l + r) >> 1;
  t[p << 1].tag[z] = t[p << 1 | 1].tag[z] = x;
  if (!x)
    t[p << 1].cnt[z] = t[p << 1 | 1].cnt[z] = 0;
  else
    t[p << 1].cnt[z] = mid - l + 1, t[p << 1 | 1].cnt[z] = r - mid;
  x = -1;
}
void build(int p, int l, int r) {
  t[p].l = l, t[p].r = r;
  for (int i = 0; i < 26; i++) t[p].cnt[i] = 0, t[p].tag[i] = -1;
  if (l == r) {
    t[p].cnt[s[l] - 'a'] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  pushup(p);
}
int query(int p, int x, int y, int z) {
  int l = t[p].l, r = t[p].r;
  if (l >= x && r <= y) return t[p].cnt[z];
  if (~t[p].tag[z]) pushdown(p, z);
  int mid = (l + r) >> 1, ans = 0;
  if (x <= mid) ans += query(p << 1, x, y, z);
  if (y > mid) ans += query(p << 1 | 1, x, y, z);
  return ans;
}
void modify(int p, int x, int y, int z) {
  int l = t[p].l, r = t[p].r;
  if (l >= x && r <= y) {
    for (int i = 0; i < 26; i++) {
      if (i == z) {
        if (t[p].cnt[i] != r - l + 1) {
          t[p].cnt[i] = r - l + 1;
          t[p].tag[i] = 1;
        }
      } else {
        if (t[p].cnt[i] != 0) {
          t[p].cnt[i] = 0;
          t[p].tag[i] = 0;
        }
      }
    }
    return;
  }
  for (int i = 0; i < 26; i++)
    if (~t[p].tag[i]) pushdown(p, i);
  int mid = (l + r) >> 1;
  if (x <= mid) modify(p << 1, x, y, z);
  if (y > mid) modify(p << 1 | 1, x, y, z);
  pushup(p);
}
void update(int p) {
  int l = t[p].l, r = t[p].r;
  if (l == r) {
    for (int i = 0; i < 26; i++)
      if (t[p].cnt[i]) s[l] = 'a' + i;
    return;
  }
  for (int i = 0; i < 26; i++)
    if (~t[p].tag[i]) pushdown(p, i);
  update(p << 1);
  update(p << 1 | 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  cin >> (s + 1);
  build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    vector<int> cnt(26);
    for (int j = 0; j < 26; j++) cnt[j] = query(1, x, y, j);
    int l = x;
    if (z) {
      for (int idx = 0; idx < 26; idx++) {
        if (!cnt[idx]) continue;
        int r = l + cnt[idx] - 1;
        modify(1, l, r, idx);
        l = r + 1;
      }
    } else {
      for (int idx = 25; idx >= 0; idx--) {
        if (!cnt[idx]) continue;
        int r = l + cnt[idx] - 1;
        modify(1, l, r, idx);
        l = r + 1;
      }
    }
  }
  update(1);
  cout << (s + 1);
  return 0;
}