- Time limit: 1.00 s
- Memory limit: 512 MB
Given a string, your task is to process operations where you cut a substring and paste it to the end 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 cut a substring from position to position .
Output
Print the final string after all the operations.
Constraints
Example
Input:
7 2 AYBABTU 3 5 3 5
Output:
AYABTUB