Problem: 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.

Input

The first line will contain two integers n, q (1 ≤ n ≤ 105, 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, <image>).

Output

Output one line, the string S after applying the queries.

Examples

Input

10 5
abacdabcda
7 10 0
5 8 1
1 4 0
3 6 0
7 10 1


Output

cbcaaaabdd

Input

10 1
agjucbvdfk
1 10 1


Output

abcdfgjkuv

Note

First sample test explanation:

<image>

<image>

<image>

<image>

<image>

Solution (in JAVA):

Solution:
/*
Keep solving problems. 
*/

import java.util.*;
import java.io.*;

public class CFA {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    int[] dx = {1, 2, 1, 1};
    int[] dy = {0, 0, -1, 1};

    char[] arr;
    int[][] tree;
    int[][] lazy;

    void build_tree(int node, int nodeStartIndex, int nodeEndIndex) {
        if(nodeStartIndex > nodeEndIndex) return; // Out of range
        if(nodeStartIndex == nodeEndIndex) { // Leaf node
            tree[node][arr[nodeStartIndex] - 'a'] = 1; // Init value
            for (int j = 0; j < 26; j++) {
                lazy[node][j] = -1;
            }
            return;
        }

        build_tree(node * 2, nodeStartIndex, (nodeStartIndex + nodeEndIndex) / 2); // Init left child
        build_tree(node * 2 + 1, 1 + (nodeStartIndex + nodeEndIndex) / 2, nodeEndIndex); // Init right child
        for (int j = 0; j < 26; j++) {
            lazy[node][j] = -1;
            tree[node][j] = tree[node * 2][j] + tree[node * 2 + 1][j]; // Init root value
        }
    }

    /**
     * Increment elements within range [queryStartIndex, queryEndIndex] with value
     */
    void update_tree(int node, int nodeStartIndex, int nodeEndIndex, int queryStartIndex, int queryEndIndex, int value, int cha) {
        if(nodeStartIndex > nodeEndIndex || nodeStartIndex > queryEndIndex || nodeEndIndex < queryStartIndex) // Current segment is not within range [i, j]
            return;
        if(nodeStartIndex >= queryStartIndex && nodeEndIndex <= queryEndIndex) { // Segment is fully within range
            tree[node][cha] = value * (nodeEndIndex - nodeStartIndex + 1);
            lazy[node][cha] = value;
            return;
        }

        //-------------
        shift(node, nodeStartIndex, nodeEndIndex, cha);
        //-------------
        update_tree(node * 2, nodeStartIndex, (nodeStartIndex + nodeEndIndex) / 2, queryStartIndex, queryEndIndex, value, cha); // Updating left child
        update_tree(node * 2 + 1, 1 + (nodeStartIndex + nodeEndIndex) / 2, nodeEndIndex, queryStartIndex, queryEndIndex, value, cha); // Updating right child

        tree[node][cha] = tree[node * 2][cha] + tree[node * 2 + 1][cha]; // Updating root
    }

    /**
     * Query tree to get max element value within range [queryStartIndex, queryEndIndex]
     */
    int query_tree(int node, int nodeStartIndex, int nodeEndIndex, int queryStartIndex, int queryEndIndex, int cha) {
        if(nodeStartIndex > nodeEndIndex || nodeStartIndex > queryEndIndex || nodeEndIndex < queryStartIndex) return 0; // Out of range
        if(nodeStartIndex >= queryStartIndex && nodeEndIndex <= queryEndIndex) // Current segment is totally within range [i, j]
            return tree[node][cha];

        //-------------
        shift(node, nodeStartIndex, nodeEndIndex, cha);
        //-------------
        int q1 = query_tree(node * 2, nodeStartIndex, (nodeStartIndex + nodeEndIndex) / 2, queryStartIndex, queryEndIndex, cha); // Query left child
        int q2 = query_tree(1 + node * 2, 1 + (nodeStartIndex + nodeEndIndex) / 2, nodeEndIndex, queryStartIndex, queryEndIndex, cha); // Query right child

        return q1 + q2;
    }

    private void shift(int node, int nodeStartIndex, int nodeEndIndex, int cha) {
        if(lazy[node][cha] != -1) { // This node needs to be updated
            if (nodeEndIndex > nodeStartIndex) {
                int mid = (nodeStartIndex + nodeEndIndex) / 2;
                tree[2 * node][cha] = (mid - nodeStartIndex + 1) * lazy[node][cha];
                tree[2 * node + 1][cha] = (nodeEndIndex - mid) * lazy[node][cha];

                lazy[node * 2][cha] = lazy[node][cha]; // Mark child as lazy
                lazy[node * 2 + 1][cha] = lazy[node][cha]; // Mark child as lazy
                lazy[node][cha] = -1; // Reset it
            }
        }
    }

    void get_tree(int node, int nodeStartIndex, int nodeEndIndex, int cha) {
        shift(node, nodeStartIndex, nodeEndIndex, cha);
        if (tree[node][cha] == 0) {
            return;
        }

        if (nodeStartIndex == nodeEndIndex) {
            arr[nodeStartIndex] = (char) (cha + 'a');
            return;
        }

        get_tree(node * 2, nodeStartIndex, (nodeStartIndex + nodeEndIndex) / 2, cha);
        get_tree(node * 2 + 1, (nodeStartIndex + nodeEndIndex) / 2 + 1, nodeEndIndex, cha);
    }

    int[] cnt;
    void solve() throws IOException {
        int n = nextInt();
        int q = nextInt();
        tree = new int[5 * n][26];
        lazy = new int[5 * n][26];
        arr = nextString().toCharArray();
        build_tree(1, 0, n - 1);

        cnt = new int[26];

        for (int iter = 0; iter < q; iter++) {
            int i = nextInt() - 1;
            int j = nextInt() - 1;
            int k = nextInt();
            for (int c = 0; c < 26; c++) {
                cnt[c] = query_tree(1, 0, n - 1, i, j, c);
            }

            int start = k == 1 ? i : j;
            for (int c = 0; c < 26; c++) {
                if (cnt[c] == 0) {
                    continue;
                }

                update_tree(1, 0, n - 1, i, j, 0, c);

                if (k == 1) {
                    update_tree(1, 0, n - 1, start, start + cnt[c] - 1, 1, c);
                    start += cnt[c];
                }
                else {
                    update_tree(1, 0, n - 1, start - (cnt[c] - 1), start, 1, c);
                    start -= cnt[c];
                }
            }
        }

        for (int c = 0; c < 26; c++) {
            get_tree(1, 0, n - 1, c);
        }

        for (int i = 0; i < n; i++) {
            out(arr[i]);
        }
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }

    long gcd(long a, long b) {
        while(a != 0 && b != 0) {
            long c = b;
            b = a % b;
            a = c;
        }
        return a + b;
    }

    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public CFA() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new CFA();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}