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%;"/>).
# LUOGU_RID: 121861782
class SegmentTreeNode:
    def __init__(self, start, end):
        self.start = start
        self.end = end
        self.value = ""
        self.left = None
        self.right = None

def build_segment_tree(string, start, end):
    if start > end:
        return None

    node = SegmentTreeNode(start, end)

    if start == end:
        node.value = string[start]
        return node

    mid = (start + end) // 2
    node.left = build_segment_tree(string, start, mid)
    node.right = build_segment_tree(string, mid + 1, end)

    if node.left:
        node.value += node.left.value
    if node.right:
        node.value += node.right.value

    return node


def update_segment_tree(node, index, value):
    if node.start == node.end == index:
        node.value = value
        return

    mid = (node.start + node.end) // 2
    if index <= mid:
        update_segment_tree(node.left, index, value)
    else:
        update_segment_tree(node.right, index, value)

    node.value = node.left.value + node.right.value


def query_segment_tree(node, start, end):
    if node.start == start and node.end == end:
        return node.value

    mid = (node.start + node.end) // 2
    if end <= mid:
        return query_segment_tree(node.left, start, end)
    elif start > mid:
        return query_segment_tree(node.right, start, end)
    else:
        left_value = query_segment_tree(node.left, start, mid)
        right_value = query_segment_tree(node.right, mid + 1, end)
        return left_value + right_value

n, m = map(int, input().split())
string = input().strip()
operations = []
for _ in range(m):
    operations.append(input().strip())
root = build_segment_tree(string, 0, n - 1)
for op in operations:
    l, r, k = map(int, op.split())
    substring = query_segment_tree(root, l - 1, r - 1)

    if k == 1:
        sorted_substring = ''.join(sorted(substring))
    else:
        sorted_substring = ''.join(sorted(substring, reverse=True))

    for i, c in enumerate(sorted_substring):
        update_segment_tree(root, l - 1 + i, c)


result = query_segment_tree(root, 0, n - 1)
print(result)
