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.
The first line will contain two integers *n*, *q* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>, 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*, <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/187c38b0d200dfc5b5249f93c000f8dee9c1180d.png" style="max-width: 100.0%;max-height: 100.0%;"/>).
// http://codeforces.com/contest/558/problem/E
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
const int MAXN = 100005;
 
struct node
{
    ll left, right, count, lazy;
} T[26][MAXN << 2];
 
char A[MAXN];
ll N, M;
 
ll pullUp(ll num, ll idx)
{
    T[num][idx].count = T[num][idx << 1].count + T[num][(idx << 1) + 1].count;
}
 
ll pushDown(ll num, ll idx)
{
    ll lazy = T[num][idx].lazy;
 
    if (lazy == 0)
    {
        T[num][idx << 1].lazy = 0;
        T[num][(idx << 1) + 1].lazy = 0;
 
        T[num][idx << 1].count = 0;
        T[num][(idx << 1) + 1].count = 0;
    }
    else if (lazy == 1)
    {
        T[num][idx << 1].lazy = 1;
        T[num][(idx << 1) + 1].lazy = 1;
 
        T[num][idx << 1].count = T[num][idx << 1].right - T[num][idx << 1].left + 1;
        T[num][(idx << 1) + 1].count = T[num][(idx << 1) + 1].right - T[num][(idx << 1) + 1].left + 1;
    }
 
    T[num][idx].lazy = -1;
}
 
ll build(int num, ll idx, ll st, ll ed)
{
    ll mid;
 
    T[num][idx].left = st;
    T[num][idx].right = ed;
    T[num][idx].lazy = -1;
 
    if (st == ed) //is leaf
    {
        if (A[st] - 'a' == num)
            T[num][idx].count = 1;
        else
            T[num][idx].count = 0;
 
        return 0;
    }
 
    mid = (st + ed) / 2;
 
    build(num, idx << 1, st, mid);
    build(num, (idx << 1) + 1, mid + 1, ed);
 
    pullUp(num, idx); //apply count
 
    return 0;
}
 
ll query(int num, ll idx, ll st, ll ed)
{
    ll mid, lret, rret;
 
    if (T[num][idx].left >= st && T[num][idx].right <= ed)
    {
        return T[num][idx].count;
    }
    if (T[num][idx].right < st || T[num][idx].left > ed)
    {
        return 0;
    }
 
    mid = (T[num][idx].left + T[num][idx].right) / 2;
 
    lret = query(num, idx << 1, st, ed);
    rret = query(num, (idx << 1) + 1, st, ed);
 
    return lret + rret;
}
 
ll update(int num, ll idx, ll st, ll ed, ll val)
{
    int mid;
 
    if (T[num][idx].left >= st && T[num][idx].right <= ed)
    {
        T[num][idx].lazy = val;
 
        if (val == 1)
            T[num][idx].count = T[num][idx].right - T[num][idx].left + 1;
        else
            T[num][idx].count = 0;
 
        return 0;
    }
    if (T[num][idx].right < st || T[num][idx].left > ed)
    {
        return 0;
    }
 
    mid = (T[num][idx].left + T[num][idx].right) / 2;
 
    pushDown(num, idx);
 
    update(num, idx << 1, st, ed, val);
    update(num, (idx << 1) + 1, st, ed, val);
 
    pullUp(num, idx);
 
    return 0;
}
 
int main()
{
    int register i, j;
    ll st, ed, val;
    ll left;
    ll lret, rret;
    int num[26];
 
    scanf("%lld %lld", &N, &M);
    scanf("%s", A + 1);
 
    for (i = 0; i < 26; i++)
    {
        build(i, 1, 1, N);
    }
 
    for (i = 1; i <= M; i++)
    {
        scanf("%lld %lld %lld", &st, &ed, &val);
 
        for (j = 0; j < 26; j++)
        {
            num[j] = 0;
        }
 
        if (val == 1) //asc
        {
            for (j = 0; j < 26; j++)
            {
                num[j] = query(j, 1, st, ed);
                update(j, 1, st, ed, 0);
            }
 
            left = st;
 
            for (j = 0; j < 26; j++)
            {
                if (num[j] > 0)
                {
                    update(j, 1, left, left + num[j] - 1, 1);
                    left = left + num[j];
                }
            }
        }
        else //desc
        {
            for (j = 0; j < 26; j++)
            {
                num[j] = query(j, 1, st, ed);
                update(j, 1, st, ed, 0);
            }
 
            left = st;
 
            for (j = 25; j >= 0; j--)
            {
                if (num[j] > 0)
                {
                    update(j, 1, left, left + num[j] - 1, 1);
                    left = left + num[j];
                }
            }
        }
    }
 
    for (i = 1; i <= N; i++)
    {
        for (j = 0; j < 26; j++)
        {
            if (query(j, 1, i, i) > 0)
            {
                putchar('a' + j);
            }
        }
    }
    printf("\n");
 
    return 0;
}