#SGM0000048. Một nhiệm vụ đơn giản (A Simple Task)
Một nhiệm vụ đơn giản (A Simple Task)
A Simple Task
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
For each query , sort substring ascending when and descending when . Print the final string.
Input
The first line contains , followed by the lowercase string . Each of the next lines contains i j k; sort non-decreasing when and non-increasing when .
Output
Print the final string.
Subtasks
-
Subtask 1 (20%): size and operation count at most 30; all other validity conditions are unchanged.
-
Subtask 2 (30%): size and operation count at most 3000; all other validity conditions are unchanged.
-
Subtask 3 (50%): full constraints:
-
-
-
Chuỗi chỉ gồm chữ thường
a..z.
Examples
Input
10 1
agjucbvdfk
1 10 1
Output
abcdfgjkuv
Explanation
Sorting the whole string in increasing order gives abcdfgjkuv.