Codeforces Round 312 (Div. 2)
E
A Simple Task
Codeforces
2300
原题
← D→
翻译中…

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* ≤ 10^{5}$, $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.

翻译中…

Note

翻译中…

First sample test explanation:

翻译中…

image

翻译中…

image

翻译中…

image

翻译中…

image

翻译中…

image

翻译中…

样例

Input #1
10 5
abacdabcda
7 10 0
5 8 1
1 4 0
3 6 0
7 10 1
Output #1
cbcaaaabdd
InputCopy OutputCopy
Input #2
10 1
agjucbvdfk
1 10 1
Output #2
abcdfgjkuv
InputCopy OutputCopy
题目信息
题号
558E
时间限制
5 s
内存限制
512 MB
标签
数据结构
排序
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。