영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
시간 제한 1초 · 메모리 제한 512 MB
Problem
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 n and m: the length of the string and the number of operations. The characters of the string are numbered 1,2,…,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 reverse a substring from position a to position b.
Output
Print the final string after all the operations.
Constraints
- 1 ≤ n, m ≤ 2 · 10^5
- 1 ≤ a ≤ b ≤ n
예제
예제 1
7 2 AYBABTU 3 4 4 7
AYAUTBB