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:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Artem Gilmudinov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Reader in = new Reader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, Reader in, PrintWriter out) {
            int n, q;
            n = in.ni();
            q = in.ni();
            String s = in.rl();
            TaskE.SegmentTree[] st = new TaskE.SegmentTree[26];
            for (int i = 0; i < 26; i++) {
                st[i] = new TaskE.SegmentTree(n);
            }
            for (int i = 0; i < n; i++) {
                int ind = s.charAt(i) - 'a';
                st[ind].update(0, st[ind].size - 1, i, i, 0, 1);
            }
            int l, r, k, curPos;
            int[] cnt = new int[26];
            for (int i = 0; i < q; i++) {
                l = in.ni() - 1;
                r = in.ni() - 1;
                k = in.ni();
                Arrays.fill(cnt, 0);
                for (int j = 0; j < 26; j++) {
                    cnt[j] = st[j].get(0, st[j].size - 1, l, r, 0);
                    st[j].update(0, st[j].size - 1, l, r, 0, 0);
                }
                //out.println(Arrays.toString(cnt));
                curPos = l;
                if (k == 1) {
                    for (int j = 0; j < 26; j++) {
                        if (cnt[j] != 0) {
                            st[j].update(0, st[j].size - 1, curPos, curPos + cnt[j] - 1, 0, 1);
                            curPos += cnt[j];
                        }
                    }
                } else {
                    for (int j = 25; j >= 0; j--) {
                        if (cnt[j] != 0) {
                            st[j].update(0, st[j].size - 1, curPos, curPos + cnt[j] - 1, 0, 1);
                            curPos += cnt[j];
                        }
                    }
                }
            }
//        for(int i = st[0].size - 1; i < st[0].size * 2 - 1; i++) {
//            System.out.print(st[0].v[i] + " ");
//        }
//        System.out.println();
//        System.out.println("++++++++++++++++++++++");
//        System.out.println(st[0].size);
//        System.out.println(st[0].get(0, st[0].size - 1, 0, 0, 0));
            for (int i = 0; i < n; i++) {
                int res = -1;
                for (int j = 0; j < 26; j++) {
                    if (st[j].get(0, st[j].size - 1, i, i, 0) != 0) {
                        res = j;
                        break;
                    }
                }
                out.print((char) ('a' + res));
            }
            out.println();
        }

        class SegmentTree {
            int[] a;
            int[] v;
            int size = 1;

            public SegmentTree(int n) {
                while (size < n) {
                    size <<= 1;
                }
                a = new int[size * 2 - 1];
                v = new int[size * 2 - 1];
                for (int i = 0; i < v.length; i++) {
                    v[i] = -1;
                    a[i] = 0;
                }
            }

            public void push(int node) {
                if (v[node] == -1) {
                    return;
                }
                v[2 * node + 1] = v[2 * node + 2] = v[node];
                v[node] = -1;
            }

            public void update(int t_l, int t_r, int q_l, int q_r, int node, int value) {

                if (q_l > q_r) {
                    return;
                }
                if (t_l == q_l && t_r == q_r) {
                    v[node] = value;
                    return;
                }
                push(node);
                int mid = t_l + (t_r - t_l) / 2;
                int left = 2 * node + 1;
                int right = 2 * node + 2;
                update(t_l, mid, q_l, Math.min(q_r, mid), left, value);
                update(mid + 1, t_r, Math.max(q_l, mid + 1), q_r, right, value);
                a[node] = (v[left] == -1 ? a[left] : v[left] * (mid - t_l + 1));
                a[node] += (v[right] == -1 ? a[right] : v[right] * (t_r - mid));
            }

            public int get(int t_l, int t_r, int q_l, int q_r, int node) {

                if (q_l > q_r) {
                    return 0;
                }
                if (t_l == q_l && t_r == q_r) {
                    if (v[node] != -1) {
                        return v[node] * (t_r - t_l + 1);
                    } else {
                        return a[node];
                    }
                }
                push(node);
                int mid = t_l + (t_r - t_l) / 2;
                int left = 2 * node + 1;
                int right = 2 * node + 2;
                int leftVal, rightVal;
                leftVal = get(t_l, mid, q_l, Math.min(q_r, mid), left);
                rightVal = get(mid + 1, t_r, Math.max(q_l, mid + 1), q_r, right);
                return leftVal + rightVal;
            }

        }

    }

    static class Reader {
        private BufferedReader in;
        private StringTokenizer st = new StringTokenizer("");
        private String delim = " ";

        public Reader(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            if (!st.hasMoreTokens()) {
                st = new StringTokenizer(rl());
            }
            return st.nextToken(delim);
        }

        public String rl() {
            try {
                return in.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public int ni() {
            return Integer.parseInt(next());
        }

    }
}