Problem Statement
Given a string S, you need to perform Q transformations of the form (a,b). For each transformation, you need to reverse the substring s[a...b]
and then print the transformed string. This change is permanently
applied on the string, i.e., each tranformation will be done on the
output of previous transformation.
Input Format
The first line of input contains the string S.
This is followed by integer Q in the next line.
Then Q lines follow, each containing two space-separated integers, a and b.
Constraints
1≤length(S)≤1000
1≤Q≤1000
0≤a≤b<length(S)
Output Format
For each transformation, print the answer in a new line.
Sample Input
abcdef
4
0 0
0 5
0 2
0 1
Sample Output
abcdef
fedcba
defcba
edfcba
Explanation
After the first operation, the string is now "abcdef".
After the second operation, the string is now "fedcba".
After the third operation, the string is now "defcba".
After the fourth operation, the string is now "edfcba".