- Time limit: 1.00 s
- Memory limit: 512 MB
Given a string, your task is to process operations where you reverse a substring of the string. What is the final string after all the operations?
Input
The first input line has two integers and : the length of the string and the number of operations. The characters of the string are numbered .
The next line has a string of length that consists of characters A–Z.
Finally, there are lines that describe the operations. Each line has two integers and : you reverse a substring from position to position .
Output
Print the final string after all the operations.
Constraints
Example
Input:
7 2 AYBABTU 3 4 4 7
Output:
AYAUTBB