Reversal

Apply M substring reversals to a string of up to 2.5 million characters and print the final result.

Easy3StringImplementationSimulationInterviewNo attempts yetTime limit1sMemory limit256 MB

Problem

A text editor holds a string of NN characters. Mirko performs MM steps. In each step he picks two numbers AA and BB and reverses the substring made of all characters from position AA to position BB, inclusive. To reverse it, he swaps the first character of the substring with the last one, the second with the second to last, and so on. Positions in the string are numbered from 11 to NN.

Write a program that finds the final state of the string after all reversals.

Input

The first line contains the initial string. It consists only of lowercase English letters, and its length NN is at most 25000002\,500\,000. The second line contains a positive integer MM (1M25001 \le M \le 2\,500), the number of steps. Each of the next MM lines contains two positive integers AA and BB (1ABN1 \le A \le B \le N) that describe one step.

Output

Print the string after all reversals on a single line.