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, k = 26;
int t[4 * N][k];
int was[4 * N];
string s;
int n;
void push(int v, int l, int r) {
  if (l == r - 1 || was[v] == -1) return;
  int m = (l + r) / 2;
  int left[26], right[26];
  fill(left, left + 26, 0);
  fill(right, right + 26, 0);
  if (!was[v]) {
    int sz = m - l;
    for (int i = 0; i < 26; i++) {
      if (sz == 0) {
        right[i] = t[v][i];
      } else {
        if (t[v][i] > sz) {
          left[i] = sz;
          right[i] = t[v][i] - sz;
          sz = 0;
        } else {
          left[i] = t[v][i];
          sz -= t[v][i];
        }
      }
    }
  } else {
    int sz = m - l;
    for (int i = 25; i > -1; i--) {
      if (sz == 0) {
        right[i] = t[v][i];
      } else {
        if (t[v][i] > sz) {
          left[i] = sz;
          right[i] = t[v][i] - sz;
          sz = 0;
        } else {
          left[i] = t[v][i];
          sz -= t[v][i];
        }
      }
    }
  }
  was[2 * v + 1] = was[v];
  was[2 * v + 2] = was[v];
  was[v] = -1;
  for (int i = 0; i < k; i++) {
    t[2 * v + 1][i] = left[i];
    t[2 * v + 2][i] = right[i];
  }
}
void build(int v, int l, int r) {
  if (l == r - 1) {
    t[v][s[l] - 'a']++;
    return;
  }
  int m = (l + r) / 2;
  build(2 * v + 1, l, m);
  build(2 * v + 2, m, r);
  for (int i = 0; i < k; i++) {
    t[v][i] = t[2 * v + 1][i] + t[2 * v + 2][i];
  }
}
vector<int> get(int v, int l, int r, int tl, int tr) {
  push(v, l, r);
  if (tl >= r || tr <= l) {
    return vector<int>(k);
  }
  if (tl <= l && r <= tr) {
    vector<int> ans(26);
    for (int i = 0; i < 26; i++) {
      ans[i] = t[v][i];
    }
    return ans;
  }
  int m = (l + r) / 2;
  auto v1 = get(2 * v + 1, l, m, tl, tr), v2 = get(2 * v + 2, m, r, tl, tr);
  vector<int> ans(k);
  for (int i = 0; i < k; i++) {
    ans[i] = v1[i] + v2[i];
  }
  return ans;
}
vector<int> cur;
void query(int v, int l, int r, int tl, int tr, bool w) {
  push(v, l, r);
  if (tl >= r || tr <= l) {
    return;
  }
  if (tl <= l && r <= tr) {
    was[v] = w;
    int left[26];
    fill(left, left + 26, 0);
    int sz = r - l;
    if (!w) {
      for (int i = 0; i < 26; i++) {
        if (!sz) break;
        if (cur[i] > sz) {
          left[i] = sz;
          cur[i] -= sz;
          sz = 0;
        } else {
          left[i] = cur[i];
          sz -= cur[i];
          cur[i] = 0;
        }
      }
    } else {
      for (int i = 25; i > -1; i--) {
        if (!sz) break;
        if (cur[i] > sz) {
          left[i] = sz;
          cur[i] -= sz;
          sz = 0;
        } else {
          left[i] = cur[i];
          sz -= cur[i];
          cur[i] = 0;
        }
      }
    }
    for (int i = 0; i < 26; i++) {
      t[v][i] = left[i];
    }
    return;
  }
  int m = (l + r) / 2;
  query(2 * v + 1, l, m, tl, tr, w);
  query(2 * v + 2, m, r, tl, tr, w);
  for (int i = 0; i < k; i++) {
    t[v][i] = t[2 * v + 1][i] + t[2 * v + 2][i];
  }
}
void print(int v, int l, int r) {
  push(v, l, r);
  if (l == r - 1) {
    for (int i = 0; i < 26; i++) {
      if (t[v][i]) {
        cout << (char)(i + 'a');
      }
    }
    return;
  }
  int m = (l + r) / 2;
  print(2 * v + 1, l, m);
  print(2 * v + 2, m, r);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> n >> q >> s;
  for (int i = 0; i < 4 * n; i++) {
    fill(t[i], t[i] + k, 0);
    was[i] = -1;
  }
  build(0, 0, n);
  while (q--) {
    int l, r, w;
    cin >> l >> r >> w;
    cur = get(0, 0, n, l - 1, r);
    query(0, 0, n, l - 1, r, !w);
  }
  print(0, 0, n);
  return 0;
}