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%;"/>).
MAX_CHAR = 26;

def sortString(str):  
    charCount = [0]*MAX_CHAR;
    stri=""
    for i in range(len(str)): 
        charCount[ord(str[i]) - ord('a')]+=1; 
    for i in range(MAX_CHAR - 1,-1, -1): 
        for j in range(charCount[i]): 
            stri=stri+chr(97+i);
    return stri

def incOrder(str): 
    charCount = [0]*MAX_CHAR;
    stri=""
    for i in range(len(str)): 
        charCount[ord(str[i]) - ord('a')]+=1; 
    for i in range(0,MAX_CHAR): 
        for j in range(charCount[i]): 
            stri=stri+chr(97+i);
    return stri

def main():
    n1, q1 = input().split()
    n=int(n1)
    q=int(q1)
    s=input()
    while q:
        i1, j1, k1 = input().split()
        i=int(i1)
        j=int(j1)
        k=int(k1)
        s1=s[:i-1]
        s2=s[i-1:j]
        s3=s[j:]
        if k==0:
            s2=sortString(s2)
        if k==1:
            s2=incOrder(s2)
        s=s1+s2+s3
        q-=1
    print(s)

main()
