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 INF = 1e9 + 123, MAXN = 2e5 + 47, MEGAINF = 1e18;
template <class T>
istream& operator>>(istream& in, vector<T>& a) {
  for (auto& i : a) in >> i;
  return in;
}
template <class T>
ostream& operator<<(ostream& out, vector<T>& a) {
  for (auto& i : a) out << i << " ";
  return out;
}
template <class T, class U>
istream& operator>>(istream& in, vector<pair<T, U>>& a) {
  for (auto& i : a) in >> i.first >> i.second;
  return in;
}
template <class T, class U>
ostream& operator<<(ostream& out, vector<pair<T, U>>& a) {
  for (auto& i : a) out << i.first << " " << i.second << endl;
  return out;
}
struct node {
  long long l, r, add, sum;
  node() {
    sum = 0;
    l = r = -1;
    add = -1;
  }
};
string s;
long long n;
vector<vector<node>> t;
void build(long long l, long long r, long long v = 1) {
  for (long long i = 0; i < 26; ++i) {
    t[v][i].l = l;
    t[v][i].r = r;
  }
  if (l == r) {
    t[v][s[l] - 'a'].sum = 1;
    return;
  }
  long long mid = l + r >> 1;
  build(l, mid, v * 2);
  build(mid + 1, r, v * 2 + 1);
  for (long long i = 0; i < 26; ++i)
    t[v][i].sum = t[v * 2][i].sum + t[v * 2 + 1][i].sum;
}
void push(long long v, long long j) {
  if (t[v][j].add == -1) return;
  t[v][j].sum = t[v][j].add * (t[v][j].r - t[v][j].l + 1);
  if (t[v][j].l != t[v][j].r) {
    t[v * 2][j].add = t[v][j].add;
    t[v * 2 + 1][j].add = t[v][j].add;
  }
  t[v][j].add = -1;
}
void update(long long l, long long r, long long val, long long j,
            long long v = 1) {
  push(v, j);
  if (t[v][j].l > r || t[v][j].r < l) return;
  if (t[v][j].l >= l && t[v][j].r <= r) {
    t[v][j].add = val;
    push(v, j);
    return;
  }
  update(l, r, val, j, v * 2);
  update(l, r, val, j, v * 2 + 1);
  t[v][j].sum = t[v * 2][j].sum + t[v * 2 + 1][j].sum;
}
long long query(long long l, long long r, long long j, long long v = 1) {
  push(v, j);
  if (t[v][j].l > r || t[v][j].r < l) return 0;
  if (t[v][j].l >= l && t[v][j].r <= r) return t[v][j].sum;
  return query(l, r, j, v * 2) + query(l, r, j, v * 2 + 1);
}
void get(long long j, long long v = 1) {
  push(v, j);
  if (!t[v][j].sum) return;
  if (t[v][j].l == t[v][j].r) {
    s[t[v][j].l] = j + 'a';
    return;
  }
  get(j, v * 2);
  get(j, v * 2 + 1);
}
signed main() {
  setlocale(LC_ALL, "rus");
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<long long> cnt(26);
  long long n, q;
  cin >> n >> q;
  cin >> s;
  t.resize(n * 4);
  for (long long i = 0; i < n * 4; ++i) t[i].resize(26);
  build(0, n - 1);
  while (q--) {
    long long l, r, up;
    cin >> l >> r >> up;
    --l, --r;
    for (long long i = 0; i < 26; ++i) cnt[i] = query(l, r, i);
    long long cur = l;
    if (!up) cur = r;
    for (long long i = 0; i < 26; ++i) {
      if (!cnt[i]) continue;
      update(l, r, 0, i);
      if (up) {
        update(cur, cur + cnt[i] - 1, 1, i);
        cur += cnt[i];
      } else {
        update(cur - cnt[i] + 1, cur, 1, i);
        cur -= cnt[i];
      }
    }
  }
  for (long long i = 0; i < 26; ++i) get(i);
  cout << s;
}