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%;"/>).
class part():
    def __init__(self, value, previous):
        self.value = value
        self.previous = previous
 
class mylist():
    def __init__(self):
        self.links = list()
        self.head = None
       
    def append(self, num):
        headlist = part(num, self.head)
        self.head = headlist
        self.links.append(headlist)
       
    def sort_substr(self, start, end, reverse):
        start -= 1
        end -= 1
        being_ch = dict()
        for j in range(97, 123):            
            being_ch[j] = 0
        part_ = self.get_part(end)
        for j in range(end-start+1):
            being_ch[part_.value] += 1
            part_ = part_.previous
        part_ = self.get_part(end)
        k = 122 if reverse == 1 else 97
        for j in range(end-start+1):
            while being_ch[k] == 0:
                k += -1 if reverse == 1 else 1
            part_.value = k
            part_ = part_.previous
            being_ch[k] -= 1
   
    def get_head(self):
        return self.head.value
   
    def get_part(self, num):
        return self.links[num]
       
n, q = map(int, input().split())
string = mylist()
for word in input():
    string.append(ord(word))
for i in range(q):
    i, j, k = map(int, input().split())
    string.sort_substr(i, j, k)
print(''.join([chr(string.get_part(i).value) for i in range(n)]))