SP8820 OKRET - Okret

Description

There is a text consisting of N characters. At each step Mirko chooses two numbers A and B and then reverses the subsequence consisting of characters between indices A and B, inclusive. Indices are 1-based. Write a program that prints the final text after all operations are made.

Input Format

The first line of input contains the initial text of length N (1 The second line contains integer M (1 Each of the following M lines contain two integer A and B (1

Output Format

In the first and only line output the final text.