#5573. CSES2072 剪切与粘贴
0
CSES2072 剪切与粘贴
Cut and Paste
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 n and m: the length of the string and the number of operations. The characters of the string are numbered 1,2,\dots,n. The next line has a string of length n that consists of characters A–Z. Finally, there are m lines that describe the operations. Each line has two integers a and b: you cut a substring from position a to position b.
Output
Print the final string after all the operations.
Constraints
Example
Input
7 2
AYBABTU
3 5
3 5
Output
AYABTUB