A Simple Task#7414

A Simple Task

2 sekundi
244,244 megabajti
Srednje

You are given a string of length and queries. Each query has the format i, j, k, meaning that you need to sort the substring consisting of the characters from position to inclusive in non-decreasing order if k = 1, or in non-increasing order if k = 0.

After processing all the queries, print the resulting string.

Vhod

The first line contains two integers and q~(1 \le n \le 10^5, 0 \le q \le 50000) — the length of the string and the number of queries, respectively.

The second line contains the string , which consists only of lowercase English letters.

Each of the next lines contains three integers and k~(1 \le i \le j \le n,~k = 0 or k = 1) describing a query.

Izhod

Print the string after performing all the queries.

Primeri

Primer 1

Loading
Loading