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 long long oo = 1e17 + 7;
const int maxN = 100005;
int n, q, st[30][4 * maxN], lazy[30][4 * maxN];
string S;
void down(int in, int l, int r, int type) {
  if (lazy[type][in] == -1) return;
  st[type][in] = lazy[type][in] * (r - l + 1);
  if (l != r) {
    lazy[type][in * 2] = lazy[type][in];
    lazy[type][in * 2 + 1] = lazy[type][in];
  }
  lazy[type][in] = -1;
}
void update(int in, int l, int r, int i, int j, int val, int type) {
  down(in, l, r, type);
  if (l > j || r < i) return;
  if (i <= l && r <= j) {
    lazy[type][in] = val;
    down(in, l, r, type);
    return;
  }
  int mid = (l + r) / 2;
  update(in * 2, l, mid, i, j, val, type);
  update(in * 2 + 1, mid + 1, r, i, j, val, type);
  st[type][in] = st[type][in * 2] + st[type][in * 2 + 1];
}
int get(int in, int l, int r, int i, int j, int type) {
  down(in, l, r, type);
  if (l > j || r < i) return 0;
  if (i <= l && r <= j) return st[type][in];
  int mid = (l + r) / 2;
  int P1 = get(in * 2, l, mid, i, j, type);
  int P2 = get(in * 2 + 1, mid + 1, r, i, j, type);
  return P1 + P2;
}
void Prepare() {
  memset(lazy, -1, sizeof lazy);
  for (int i = 1; i <= n; i++) {
    int type = S[i] - 'a' + 1;
    update(1, 1, n, i, i, 1, type);
  }
}
void Solve() {
  for (int t = 1; t <= q; t++) {
    int l, r, k;
    cin >> l >> r >> k;
    if (k == 0) {
      int all = l;
      for (int i = 26; i >= 1; i--) {
        int many = get(1, 1, n, l, r, i);
        update(1, 1, n, l, r, 0, i);
        if (many != 0) update(1, 1, n, all, all + many - 1, 1, i);
        all += many;
      }
    }
    if (k == 1) {
      int all = l;
      for (int i = 1; i <= 26; i++) {
        int many = get(1, 1, n, l, r, i);
        update(1, 1, n, l, r, 0, i);
        if (many != 0) update(1, 1, n, all, all + many - 1, 1, i);
        all += many;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 26; j++)
      if (get(1, 1, n, i, i, j) == 1) cout << char(j + 'a' - 1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  cin >> S;
  S = " " + S;
  Prepare();
  Solve();
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}