#include <bits/stdc++.h>
struct int_26 {
  int has[30];
  void res(void) {
    memset(has, 0, sizeof(has));
    return;
  }
  int_26 friend operator+(int_26 x, int_26 y) {
    int_26 ans;
    for (int i = 1; i <= 26; i++) ans.has[i] = x.has[i] + y.has[i];
    return ans;
  }
} isr;
struct trnt {
  int_26 val;
  int lzt;
} tr[1000000];
int n, q;
int ans[1000000];
char cmd[1000000];
void pushup(int spc) {
  tr[spc].val = tr[spc << 1].val + tr[spc << 1 | 1].val;
  return;
}
void pushdown(int spc, int l, int r) {
  if (tr[spc].lzt) {
    int mid = (l + r) >> 1;
    tr[spc << 1].lzt = tr[spc].lzt;
    tr[spc << 1 | 1].lzt = tr[spc].lzt;
    tr[spc].lzt = 0;
    tr[spc << 1].val.res();
    tr[spc << 1 | 1].val.res();
    tr[spc << 1].val.has[tr[spc << 1].lzt] = mid - l + 1;
    tr[spc << 1 | 1].val.has[tr[spc << 1 | 1].lzt] = r - mid;
  }
  return;
}
void build(int spc, int l, int r) {
  if (l == r) {
    tr[spc].val.has[cmd[l] - 'a' + 1] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(spc << 1, l, mid);
  build(spc << 1 | 1, mid + 1, r);
  pushup(spc);
  return;
}
void update(int l, int r, int ll, int rr, int spc, int v) {
  if (l > rr || ll > r) return;
  if (ll <= l && r <= rr) {
    tr[spc].val.res();
    tr[spc].val.has[v] = r - l + 1;
    tr[spc].lzt = v;
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(spc, l, r);
  update(l, mid, ll, rr, spc << 1, v);
  update(mid + 1, r, ll, rr, spc << 1 | 1, v);
  pushup(spc);
  return;
}
int_26 query(int l, int r, int ll, int rr, int spc) {
  if (l > rr || ll > r) return isr;
  if (ll <= l && r <= rr) return tr[spc].val;
  int mid = (l + r) >> 1;
  pushdown(spc, l, r);
  return query(l, mid, ll, rr, spc << 1) +
         query(mid + 1, r, ll, rr, spc << 1 | 1);
}
void S_pushdown(int l, int r, int spc) {
  if (l == r) {
    for (int i = 1; i <= 26; i++)
      if (tr[spc].val.has[i]) {
        ans[l] = i;
        break;
      }
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(spc, l, r);
  S_pushdown(l, mid, spc << 1);
  S_pushdown(mid + 1, r, spc << 1 | 1);
  return;
}
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", cmd + 1);
  build(1, 1, n);
  while (q--) {
    int l, r, op;
    scanf("%d%d%d", &l, &r, &op);
    if (l > r) std::swap(l, r);
    int_26 tmp = query(1, n, l, r, 1);
    if (op) {
      int sta = l;
      for (int i = 1; i <= 26; i++) {
        if (!tmp.has[i]) continue;
        update(1, n, sta, sta + tmp.has[i] - 1, 1, i);
        sta += tmp.has[i];
      }
    } else {
      int sta = l;
      for (int i = 26; i; i--) {
        if (!tmp.has[i]) continue;
        update(1, n, sta, sta + tmp.has[i] - 1, 1, i);
        sta += tmp.has[i];
      }
    }
  }
  S_pushdown(1, n, 1);
  for (int i = 1; i <= n; i++) printf("%c", ans[i] + 'a' - 1);
  return 0;
}

### Prompt

In cpp, your task is to solve the following 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>

### Response

```cpp
#include <bits/stdc++.h>
struct int_26 {
  int has[30];
  void res(void) {
    memset(has, 0, sizeof(has));
    return;
  }
  int_26 friend operator+(int_26 x, int_26 y) {
    int_26 ans;
    for (int i = 1; i <= 26; i++) ans.has[i] = x.has[i] + y.has[i];
    return ans;
  }
} isr;
struct trnt {
  int_26 val;
  int lzt;
} tr[1000000];
int n, q;
int ans[1000000];
char cmd[1000000];
void pushup(int spc) {
  tr[spc].val = tr[spc << 1].val + tr[spc << 1 | 1].val;
  return;
}
void pushdown(int spc, int l, int r) {
  if (tr[spc].lzt) {
    int mid = (l + r) >> 1;
    tr[spc << 1].lzt = tr[spc].lzt;
    tr[spc << 1 | 1].lzt = tr[spc].lzt;
    tr[spc].lzt = 0;
    tr[spc << 1].val.res();
    tr[spc << 1 | 1].val.res();
    tr[spc << 1].val.has[tr[spc << 1].lzt] = mid - l + 1;
    tr[spc << 1 | 1].val.has[tr[spc << 1 | 1].lzt] = r - mid;
  }
  return;
}
void build(int spc, int l, int r) {
  if (l == r) {
    tr[spc].val.has[cmd[l] - 'a' + 1] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(spc << 1, l, mid);
  build(spc << 1 | 1, mid + 1, r);
  pushup(spc);
  return;
}
void update(int l, int r, int ll, int rr, int spc, int v) {
  if (l > rr || ll > r) return;
  if (ll <= l && r <= rr) {
    tr[spc].val.res();
    tr[spc].val.has[v] = r - l + 1;
    tr[spc].lzt = v;
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(spc, l, r);
  update(l, mid, ll, rr, spc << 1, v);
  update(mid + 1, r, ll, rr, spc << 1 | 1, v);
  pushup(spc);
  return;
}
int_26 query(int l, int r, int ll, int rr, int spc) {
  if (l > rr || ll > r) return isr;
  if (ll <= l && r <= rr) return tr[spc].val;
  int mid = (l + r) >> 1;
  pushdown(spc, l, r);
  return query(l, mid, ll, rr, spc << 1) +
         query(mid + 1, r, ll, rr, spc << 1 | 1);
}
void S_pushdown(int l, int r, int spc) {
  if (l == r) {
    for (int i = 1; i <= 26; i++)
      if (tr[spc].val.has[i]) {
        ans[l] = i;
        break;
      }
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(spc, l, r);
  S_pushdown(l, mid, spc << 1);
  S_pushdown(mid + 1, r, spc << 1 | 1);
  return;
}
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", cmd + 1);
  build(1, 1, n);
  while (q--) {
    int l, r, op;
    scanf("%d%d%d", &l, &r, &op);
    if (l > r) std::swap(l, r);
    int_26 tmp = query(1, n, l, r, 1);
    if (op) {
      int sta = l;
      for (int i = 1; i <= 26; i++) {
        if (!tmp.has[i]) continue;
        update(1, n, sta, sta + tmp.has[i] - 1, 1, i);
        sta += tmp.has[i];
      }
    } else {
      int sta = l;
      for (int i = 26; i; i--) {
        if (!tmp.has[i]) continue;
        update(1, n, sta, sta + tmp.has[i] - 1, 1, i);
        sta += tmp.has[i];
      }
    }
  }
  S_pushdown(1, n, 1);
  for (int i = 1; i <= n; i++) printf("%c", ans[i] + 'a' - 1);
  return 0;
}

```