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;
struct LazySegmentTree {
  vector<int> arr;
  int n;
  vector<int> tree, lazy, marked;
  LazySegmentTree(vector<int> &a) {
    arr = a;
    n = (int)a.size();
    tree.resize(4 * n);
    lazy.resize(4 * n);
    marked.resize(4 * n, 0);
    build(1, 0, n - 1);
  }
  LazySegmentTree(int cap) {
    n = cap;
    arr.resize(n, 0);
    tree.resize(4 * n);
    lazy.resize(4 * n);
  }
  int op(int a, int b) { return (a + b); }
  void build(int v, int tl, int tr) {
    if (tl == tr) {
      tree[v] = (arr[tl]);
    } else {
      int tm = (tl + tr) / 2;
      build(v * 2, tl, tm);
      build(v * 2 + 1, tm + 1, tr);
      tree[v] = op(tree[v * 2], tree[v * 2 + 1]);
    }
  }
  void push(int v, int tl, int tr) {
    if (marked[v]) {
      int tm = (tl + tr) >> 1;
      marked[v] = false;
      marked[v * 2] = true;
      marked[v * 2 + 1] = true;
      tree[v * 2] = lazy[v] * (tm - tl + 1);
      tree[v * 2 + 1] = lazy[v] * (tr - tm);
      lazy[v * 2] = lazy[v * 2 + 1] = lazy[v];
    }
  }
  void update(int v, int tl, int tr, int l, int r, int change) {
    if (l > r) return;
    if (l == tl && tr == r) {
      tree[v] = change * (tr - tl + 1);
      lazy[v] = change;
      marked[v] = true;
    } else {
      push(v, tl, tr);
      int tm = (tl + tr) / 2;
      update(v * 2, tl, tm, l, min(r, tm), change);
      update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, change);
      tree[v] = op(tree[v * 2], tree[v * 2 + 1]);
    }
  }
  int query(int v, int tl, int tr, int l, int r) {
    if (l > r) return 0;
    if (l <= tl && tr <= r) return tree[v];
    push(v, tl, tr);
    int tm = (tl + tr) / 2;
    return op(query(v * 2, tl, tm, l, min(r, tm)),
              query(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
  }
  void update(int val, int l, int r) { update(1, 0, n - 1, l, r, val); }
  int query(int l, int r) { return query(1, 0, n - 1, l, r); }
};
const int N = 26;
void solve() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<LazySegmentTree> Trees;
  for (int i = 0; i < N; i++) {
    vector<int> arr(n, 0);
    for (int j = 0; j < n; j++) arr[j] = (s[j] == 'a' + i);
    Trees.push_back(LazySegmentTree(arr));
  }
  while (q--) {
    int i, j, k;
    cin >> i >> j >> k;
    i--, j--;
    vector<int> cnt(26);
    for (int t = 0; t < N; t++) {
      cnt[t] = Trees[t].query(i, j);
    };
    if (k == 1) {
      int prev = i;
      for (int t = 0; t < N; t++) {
        Trees[t].update(0, i, j);
        Trees[t].update(1, prev, prev + cnt[t] - 1);
        prev += cnt[t];
      }
    } else {
      int prev = j;
      for (int t = 0; t < N; t++) {
        Trees[t].update(0, i, j);
        Trees[t].update(1, prev - cnt[t] + 1, prev);
        prev -= cnt[t];
      }
    }
  }
  string ans;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < N; j++) {
      if (Trees[j].query(i, i)) {
        ans.push_back(char('a' + j));
        break;
      }
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}