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 = 4e5 + 10;
string s;
int tree[N][26], lazy[N][26];
void build(int pos, int l, int r) {
  if (l == r) {
    tree[pos][s[l] - 'a'] = 1;
    for (int i = 0; i < 26; ++i) lazy[pos][i] = -1;
    return;
  }
  int mid = (l + r) / 2;
  build(2 * pos + 1, l, mid);
  build(2 * pos + 2, mid + 1, r);
  for (int i = 0; i < 26; ++i)
    tree[pos][i] = tree[2 * pos + 1][i] + tree[2 * pos + 2][i],
    lazy[pos][i] = -1;
}
void update(int pos, int l, int r, int a, int b, int val, int al) {
  if (lazy[pos][al] != -1) {
    tree[pos][al] = lazy[pos][al] * (r - l + 1);
    if (l != r)
      lazy[2 * pos + 1][al] = lazy[pos][al],
                     lazy[2 * pos + 2][al] = lazy[pos][al];
    lazy[pos][al] = -1;
  }
  if (a <= l && r <= b) {
    lazy[pos][al] = val;
    tree[pos][al] = lazy[pos][al] * (r - l + 1);
    if (l != r)
      lazy[2 * pos + 1][al] = lazy[pos][al],
                     lazy[2 * pos + 2][al] = lazy[pos][al];
    lazy[pos][al] = -1;
    return;
  }
  if (r < a || b < l) return;
  int mid = (l + r) / 2;
  update(2 * pos + 1, l, mid, a, b, val, al);
  update(2 * pos + 2, mid + 1, r, a, b, val, al);
  tree[pos][al] = tree[2 * pos + 1][al] + tree[2 * pos + 2][al];
}
int querry(int pos, int l, int r, int a, int b, int al) {
  if (l > b || r < a) return 0;
  if (lazy[pos][al] != -1) {
    tree[pos][al] = lazy[pos][al] * (r - l + 1);
    if (l != r)
      lazy[2 * pos + 1][al] = lazy[pos][al],
                     lazy[2 * pos + 2][al] = lazy[pos][al];
    lazy[pos][al] = -1;
  }
  if (a <= l && r <= b) return tree[pos][al];
  int mid = (l + r) / 2;
  return querry(2 * pos + 1, l, mid, a, b, al) +
         querry(2 * pos + 2, mid + 1, r, a, b, al);
}
void get(int pos, int l, int r, int al) {
  if (lazy[pos][al] != -1) {
    tree[pos][al] = lazy[pos][al] * (r - l + 1);
    if (l != r)
      lazy[2 * pos + 1][al] = lazy[pos][al],
                     lazy[2 * pos + 2][al] = lazy[pos][al];
    lazy[pos][al] = -1;
  }
  if (tree[pos][al] == 0) return;
  if (l == r) {
    s[l] = al + 'a';
    return;
  }
  int mid = (l + r) / 2;
  get(2 * pos + 1, l, mid, al);
  get(2 * pos + 2, mid + 1, r, al);
}
int cnt[26];
int main() {
  int i, j, a, b, n, m, k;
  cin >> n >> m >> s;
  build(0, 0, n - 1);
  for (i = 0; i < m; ++i) {
    scanf("%d%d%d", &a, &b, &k);
    int cur = --a;
    --b;
    if (k == 0) cur = b;
    for (j = 0; j < 26; ++j) cnt[j] = querry(0, 0, n - 1, a, b, j);
    for (j = 0; j < 26; ++j) {
      if (cnt[j] == 0) continue;
      update(0, 0, n - 1, a, b, 0, j);
      if (k) {
        update(0, 0, n - 1, cur, cur + cnt[j] - 1, 1, j);
        cur += cnt[j];
      } else {
        update(0, 0, n - 1, cur - cnt[j] + 1, cur, 1, j);
        cur -= cnt[j];
      }
    }
  }
  for (i = 0; i < 26; ++i) get(0, 0, n - 1, i);
  cout << s << endl;
}