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:
//package cf312;

import java.io.*;
import java.util.StringTokenizer;
import java.util.function.Function;

public class ETemplateTestDumb {
    static boolean CONSTRUCTIVE = false;
    static long BIG = (long) 2e9;
    static int n;

    public static void solve(Reader sc, PrintWriter out) {
        n = sc.nextInt();
        int q = sc.nextInt();
        char[] arr = sc.next().toCharArray();
        SegTree[] roots = new SegTree[26];
        for (int j = 0; j < 26; j++) {
            char c = (char) ('a' + j);
            roots[j] = new SegTree(arr, c);
        }
//        if (arr[0] == 'b' && arr[1] == 't') throw new IllegalStateException();
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            boolean increasing = sc.nextInt() == 1;

            int index = l;
            if (increasing) {
                for (int let = 0; let < 26; let++) {
                    int count = roots[let].getRange(l, r);
                    if (count > 0) {
                        roots[let].updateRange(l, r, 0);
                        roots[let].updateRange(index, index + count - 1, 1);
                    }
                    index += count;
                }
            } else {
                for (int let = 25; let >= 0; let--) {
                    int count = roots[let].getRange(l, r);
                    if (count > 0) {
                        roots[let].updateRange(l, r, 0);
                        roots[let].updateRange(index, index + count - 1, 1);
                    }
                    index += count;
                }
            }
        }
        print(n, roots, out);
    }

    static void print(int n, SegTree[] roots, PrintWriter out) {
        char[] arr = new char[n];
        for (int i = 0; i < n; i++) {
            for (int c = 0; c < 26; c++) {
                if (roots[c].get(i) > 0) {
                    arr[i] = (char) ('a' + c);
                    break;
                }
            }
        }
        out.println(new String(arr));
    }

    public static void main(String[] args) throws IOException {
        Reader in = null;
        PrintWriter out = null;
        for (String arg : args) {
            if (arg.startsWith("input")) {
                in = new Reader(arg);
            } else if (arg.startsWith("output")) {
                out = new PrintWriter(new FileWriter(arg));
            }
        }
        if (in == null) in = new Reader();
        if (out == null) out = new PrintWriter(new OutputStreamWriter(System.out));

        solve(in, out);

        out.flush();
    }

    static class Tester {
        public static void main(String[] args) throws IOException {
            Validator validator = new Validator();

            System.out.println("SAMPLE TESTS:");
            File currentDir = new File(".");
            long before;
            long after;
            for (File inputFile : currentDir.listFiles()) {
                if (!inputFile.getName().matches("input[0-9]")) continue;
                int number = Integer.parseInt(inputFile.getName().substring(5));
                System.out.printf("Test %d: \n", number);

                before = System.nanoTime();
                String outputFileName = "output" + inputFile.getName().substring(5);
                ETemplateTestDumb.main(new String[]{inputFile.getName(), outputFileName});
                after = System.nanoTime();

                File outputFile = new File("output" + number);
                if (!outputFile.exists()) {
                    throw new IllegalStateException("Missing output file " + outputFile);
                }

                // TODO if verifier is implemented, remove this
                if (CONSTRUCTIVE) {
                    System.out.println("INPUT:");
                    printFile(inputFile);
                    System.out.printf("\nOUTPUT: (%d milliseconds)\n", (after - before) / 1000000L);
                    printFile(outputFile);
                    continue;
                }

                if (validator.validate(inputFile, outputFile)) {
                    System.out.printf("OK (%d milliseconds)\n", (after - before) / 1000000L);
                } else {
                    System.out.println("FAILED");
                    System.out.println("\nInput: ");
                    printFile(inputFile);
                    System.out.println("\nIncorrect Output: ");
                    printFile(outputFile);
                    return;
                }
            }
            System.out.println("\n-----------------\n");

            File sightTestInput = new File("input-sight");
            if (sightTestInput.exists()) {
                System.out.println("Running sight test... Input:");
                printFile(sightTestInput);
                before = System.nanoTime();
                System.out.println("\nOutput: ");
                ETemplateTestDumb.main(new String[]{"input-sight"});
                after = System.nanoTime();
                System.out.printf("(%d milliseconds)\n", (after - before) / 1000000L);
                System.out.println("\n-----------------\n");
            }

            File bigTestInput = new File("input-big");
            if (bigTestInput.exists()) {
                System.out.println("Running big test...");
                before = System.nanoTime();
                ETemplateTestDumb.main(new String[]{"input-big"});
                after = System.nanoTime();
                System.out.printf("(%d milliseconds)\n", (after - before) / 1000000L);
            }
        }

        static void printFile(File file) throws FileNotFoundException {
            BufferedReader reader = new BufferedReader(new FileReader(file));
            reader.lines().forEach(System.out::println);
        }
    }

    static class Validator {
        boolean validate(File inputFile, File outputFile) throws IOException {
            int number = Integer.parseInt(inputFile.getName().substring(5));
            File expectedOutputFile = new File("expected-output" + number);
            if (CONSTRUCTIVE || !expectedOutputFile.exists()) {
                return validateManual(inputFile, outputFile);
            }
            return areSame(outputFile, expectedOutputFile);
        }

        private boolean validateManual(File inputFile, File outputFile) throws IOException {
            // OPTION 1: validate against naive solution
//            Naive.main(new String[] {inputFile.getName()})


            // OPTION 2: Validate output against input (typically for constructive problems)
            Reader inputReader = new Reader(inputFile.getName());
            Reader outputReader = new Reader(outputFile.getName());

            // TODO implement manual validation

            throw new IllegalStateException("Missing expected output file");
        }

        private boolean areSame(File file1, File file2) throws IOException {
            BufferedReader reader1 = new BufferedReader(new FileReader(file1));
            BufferedReader reader2 = new BufferedReader(new FileReader(file2));

            String line1;
            while ((line1 = reader1.readLine()) != null) {
                String line2 = reader2.readLine();
                if (line2 == null) line2 = ""; // ok if one has an extra newline
                if (!line1.trim().equals(line2.trim())) {
                    return false;
                }
            }
            String line2;
            while ((line2 = reader2.readLine()) != null) {
                if (!line2.trim().isEmpty()) {
                    return false;
                }
            }
            return true;
        }

    }

    static class Naive {
        public static void solveNaive(Reader in, FileWriter out) {

        }

        public static void main(String[] args) throws IOException {
            Reader in = null;
            PrintWriter out = null;
            for (String arg : args) {
                if (arg.startsWith("input")) {
                    in = new Reader(arg);
                } else if (arg.startsWith("output")) {
                    out = new PrintWriter(new FileWriter(arg));
                }
            }
            if (in == null) in = new Reader();
            if (out == null) out = new PrintWriter(new OutputStreamWriter(System.out));

            int tests = in.nextInt();
            for (int t = 0; t < tests; t++) {
                solve(in, out);
            }

            out.flush();
            out.close();
        }
    }

    // return highest in that still returns true
    // invariant:
    // -    indicator(min) = true
    // -    indicator(max+1) = false
    static int binarySearch(int min, int max, Function<Integer, Boolean> indicator) {
        int a = min;
        int b = max;
        while (a != b) {
            int mid = (a % 2 != b % 2) ? 1 + (a + b) / 2 : (a + b) / 2;
            if (indicator.apply(mid)) {
                a = mid;
            } else {
                b = mid - 1;
            }
        }
        return a;
    }

    static class SegTree {
        final int[] vals;
        final int[] lazyUpdates;

        SegTree(char[] arr, char c) {
            vals = new int[4*n];
            lazyUpdates = new int[4*n];
            for(int i = 0; i < 4*n; i++) lazyUpdates[i] = -1;
            construct(1, 0, n-1, arr ,c);
        }

        private void construct(int v, int a, int b, char[] arr, char c) {
            if (a == b) {
                vals[v] = c == arr[a] ? 1 : 0;
            } else {
                int mid = (a+b)/2;
                construct(2*v, a, mid, arr, c);
                construct(2*v+1, mid+1, b, arr, c);
                vals[v] = vals[2*v] + vals[2*v+1];
            }
        }

        void update(int index, int setTo) {
            updateRange(index, index, setTo);
        }

        void updateRange(int l, int r, int setTo) {
            updateRange(1, 0, n-1, l, r, setTo);
        }

        private void updateRange(int v, int a, int b, int l, int r, int setTo) {
            // enforce
            if (l < a || r > b) {
                throw new IllegalStateException(
                        String.format("[%d %d] out of range of [%d %d]", l, r, a, b));
            }

            int val = vals[v];
            int lazyUpdate = lazyUpdates[v];

            if (l == a && r == b) {
                lazyUpdates[v] = setTo;
                vals[v] = setTo * (r - l + 1);
            } else {
                lazyUpdates[v] = -1;
                if (lazyUpdate >= 0) {
                    // apply existing update to everything outside of [l, r]
                    if (l > a) updateRange(v, a, b, a, l - 1, lazyUpdate);
                    if (r < b) updateRange(v, a, b, r + 1, b, lazyUpdate);
                }

                int mid = (a+b)/2;
                if (l <= mid) {
                    updateRange(2*v, a, mid, l, Math.min(r, mid), setTo);
                }
                if (r > mid) {
                    updateRange(2*v+1, mid+1, b, Math.max(mid + 1, l), r, setTo);
                }
                vals[v] = vals[2*v] + vals[2*v+1];
            }
        }

        int get(int index) {
            return getRange(index, index);
        }

        int getRange(int l, int r) {
            return getRange(1, 0, n-1, l, r);
        }

        private int getRange(int v, int a, int b, int l, int r) {
            if (r < l) throw new IllegalStateException();
            if (l < a || r > b) throw new IllegalStateException();

            int val = vals[v];
            int lazyUpdate = lazyUpdates[v];

            if (l == a && r == b) {
                return val;
            }

            int mid = (a+b)/2;
            if (lazyUpdate >= 0) {
                return lazyUpdate * (r-l+1);
            }

            int ret = 0;
            if (l <= mid) {
                ret = getRange(2*v, a, mid, l, Math.min(mid, r));
            }
            if (r >= mid + 1) {
                ret += getRange(2*v+1, mid+1, b, Math.max(l, mid + 1), r);
            }
            return ret;
        }

    }

    static long pair(int x, int y) {
        return x * BIG + y;
    }

    static int x(long pair) {
        return (int) (pair / BIG);
    }

    static int y(long pair) {
        return (int) (pair % BIG);
    }

    static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        public Reader(String fileName) throws FileNotFoundException {
            reader = new BufferedReader(new FileReader(fileName));
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}