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,q=[int(x) for x in input().split()]
s=input()
L=[]
M=[]
for i in range(q):
    i,j,k=[int(x) for x in input().split()]
    if k==0:
        try:
            if i< min(L) and j in L:
                 s=s[:i-1]+"".join(sorted(s[i-1:min(L)-1],reverse=True))+s[min(L)-1:]
                 if i in M and min(L)-1 in M:
                     del M[i-1:min(L)-1]
                 L.extend(range(i,min(L)))
            elif  i in L and j>max(L):
                 s=s[:max(L)]+"".join(sorted(s[max(L):j],reverse=True))+s[j:]
                 if  max(L)+1 in M and j in M:
                      del M[max(L):j]
                 L.extend(range(max(L)+1,j+1))
            elif j not in L and i not in L:
                  s=s[:i-1]+"".join(sorted(s[i-1:j],reverse=True))+s[j:]
                  if i in M and  j in M:
                      del M[i-1:j]
                  L.extend(range(i,j+1))
            else:
                 pass
        except ValueError:
            s=s[:i-1]+"".join(sorted(s[i-1:j],reverse=True))+s[j:]
            if i in M and  j in M:
                del M[i-1:j]
            
            L.extend(range(i,j+1))
        L.sort()
    else:
        try:
            if i< min(M) and j in M:
                s=s[:i-1]+"".join(sorted(s[i-1:min(M)-1]))+s[min(M)-1:]
                if i in L and min(M)-1 in L:
                    del L[i-1:min(M)-1]
                M.extend(range(i,min(M)))
            
            
        
            elif  i in L and j>max(L):
                s=s[:max(L)]+"".join(sorted(s[max(M):j]))+s[j:]
                if max(M)+1 in L and  j in L:
                    del L[max(M):j]
                M.extend(range(max(M)+1,j+1))
            
            elif j not in M and i not in M:
                 s=s[:i-1]+"".join(sorted(s[i-1:j]))+s[j:]
                 if i in L and  j in L:
                     del L[i-1:j]
                 M.extend(range(i,j+1))
              
            else:
                pass
            
        except ValueError:
            s=s[:i-1]+"".join(sorted(s[i-1:j]))+s[j:]
            if i in L and  j in L:
                del L[i-1:j]
            M.extend(range(i,j+1))   
        M.sort()
        
        
            
print(s)