10861086 SUSTech Online Judge
Problem 1086 --String Reverse

1086: String Reverse

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 30  Solved: 7
[Submit][Status][Web Board]

Description

Wavator has a string(length N).

At each step he chooses two numbers A and B and then reverses the subsequence between indices A and B(Both are 1-based).

M steps in total;

He wants to know the final text, please help him.

Input

The first line is the initial text of length N (1 ≤ N ≤ 2500000).
The second line is M (1 ≤ M ≤ 3000).
Each of the following M lines contain two integer A and B (1 ≤ A ≤ B ≤ N).

Output

In the first and only line output the final text.

Sample Input

wavator
3
1 7
3 5
1 5

Sample Output

tavoraw

HINT

Note the length of string and the amount of change.

Source

 

[Submit][Status]