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%;"/>).
import io
import os
import sys

# not mine

def blockfill(s, cnt, order):
    if order == 0:
        return
    cur = 0 if order == 1 else 25
    idx = 0
    while idx < len(s):
        while cnt[cur] == 0:
            cur += order
        s[idx] = chr(97+cur)
        cnt[cur] -= 1
        idx += 1

def blocksort(s, order):
    cnt = [0] * 26
    for char in s:
        cnt[ord(char)-97] += 1
    blockfill(s, cnt, order)


class Block:
    def __init__(self):
        self.size = 0
        self.string = []
        self.cnt = [0] * 26
        self.order = 0

    def eval(self):
        if not self.order:
            return
        blockfill(self.string, self.cnt, self.order)
        self.order = 0


class SqrtDecomposition:
    def __init__(self, s):
        # string s should have been converted to list
        self.n = len(s)
        self.size = int(self.n ** (1/2)) + 1
        self.m = (self.n - 1) // self.size + 1
        self.blocks = []

        for i in range(self.m):
            l, r = i * self.size, min((i+1) * self.size, self.n)
            self.blocks.append(Block())
            self.blocks[i].order = 0
            self.blocks[i].size = r - l
            for j in range(l, r):
                self.blocks[i].string += s[j]
                self.blocks[i].cnt[ord(s[j])-97] += 1

    def sort(self, l, r, order):
        r -= 1
        lb, rb = l // self.size, r // self.size
        u, v = l - lb*self.size, r - rb*self.size
        
        if lb == rb:
            self.blocks[lb].eval()
            tstr = self.blocks[lb].string[u:v+1]
            blocksort(tstr, order)
            self.blocks[lb].string[u:v+1] = tstr
        else:
            tmpcnt = [0] * 26
            self.blocks[lb].eval()
            self.blocks[rb].eval()

            lstr = self.blocks[lb].string[u:]
            rstr = self.blocks[rb].string[:v+1]
            blocksort(lstr, order)
            blocksort(rstr, order)

            for char in lstr:
                tmpcnt[ord(char)-97] += 1
                self.blocks[lb].cnt[ord(char)-97] -= 1
            for cur in range(lb+1, rb):
                for pos in range(26):
                    tmpcnt[pos] += self.blocks[cur].cnt[pos]
                    self.blocks[cur].cnt[pos] = 0
            for char in rstr:
                tmpcnt[ord(char)-97] += 1
                self.blocks[rb].cnt[ord(char)-97] -= 1
            
            cur = 0 if order == 1 else 25
            idx = 0
            while idx < len(lstr):
                while tmpcnt[cur] == 0:
                    cur += order
                lstr[idx] = chr(97+cur)
                self.blocks[lb].cnt[cur] += 1
                tmpcnt[cur] -= 1
                idx += 1

            cur = 0 if order == 1 else 25
            for i in range(lb+1, rb):
                si = self.blocks[i].size
                while si:
                    if tmpcnt[cur] > si:
                        self.blocks[i].cnt[cur] += si
                        tmpcnt[cur] -= si
                        si = 0
                    else:
                        si -= tmpcnt[cur]
                        self.blocks[i].cnt[cur] += tmpcnt[cur]
                        tmpcnt[cur] = 0
                        cur += order
                self.blocks[i].order = order

            cur = 0 if order == 1 else 25
            idx = 0
            while idx < len(rstr):
                while tmpcnt[cur] == 0:
                    cur += order
                rstr[idx] = chr(97+cur)
                self.blocks[rb].cnt[cur] += 1
                tmpcnt[cur] -= 1
                idx += 1

            self.blocks[lb].string[u:] = lstr
            self.blocks[rb].string[:v+1] = rstr

    def print(self):
        for i in range(self.m):
            self.blocks[i].eval()
            sys.stdout.write("".join(self.blocks[i].string))
        print()


def main():
    n, q = [int(x) for x in input().split()]
    s = list(strput().rstrip())
    sqdec = SqrtDecomposition(s)
    for qq in range(q):
        i, j, k = [int(x) for x in input().split()]
        order = 1 if k else -1
        sqdec.sort(i-1, j, order)
    sqdec.print()


pypyin = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
cpyin = sys.stdin.readline
input = pypyin if 'PyPy' in sys.version else cpyin

def strput():
    return input().decode() if 'PyPy' in sys.version else input()

if __name__ == "__main__":
    main()