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%;"/>).
n = int(input())

q = int(input())

str = input()

if len(str) > n:
    str = str[0:n]
elif len(str) < n:
    for chr in range(n-len(str)):
        str += "o"

requests = {}

for a in range(q):
    i = int(input())
    j = int(input())
    k = int(input())
    requests[a] = [i, j, k]

##requests = {0: [7, 10, 0],
##1:[5, 8, 1],
##2:[1, 4, 0],
##3:[3, 6, 0],
##4:[7, 10, 1]}

for a in range(q):
    #print("Request #%d" % (a+1))

    start = requests[a][0] - 1
    #print("start %d" % (start+1))

    end = requests[a][1]
    #print("end %d" % (end))

    con = requests[a][2]
    #print("condition %d" % (con))
    
    if con == 1:
        #print("beginning: %s" % (str))

        res = str[0:start]
        #print("1: %s" % (res))
        
        res += "".join(sorted(str[start:end]))
        #print("1: %s" % (res))
        
        res += str[end:len(str)]
        #print("1: %s" % (res))
        
        str = res
        #print("res: %s\n" % (str))
        continue
    
    elif con == 0:
        #print("beginning: %s" % (str))

        res = str[0:start]
        #print("0: %s" % (res))
        
        res += "".join(reversed(sorted(str[start:end])))
        #print("0: %s" % (res))
        
        res += str[end:len(str)]
        #print("0: %s" % (res))
        
        str = res
        #print("res: %s\n" % (str))
        continue
                                                                                                         
print(str)
