跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1622. A Simple Task

    ID: 1628 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数据结构排序字符串编程与模拟挑战难度共享题库Codeforces英文题面题目来源题面语言

A Simple Task

题目描述

E. A Simple Task
time limit per test
5 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

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≤50000), 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≤ijn, ).

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:


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 1146 题。保留原作者与原赛事署名。