Reverse
Write a program which reads a sequence of integers A={a0,a1,...,an−1} and reverse specified elements by a list of the following operation:
reverse(b,e): reverse the order of ab,ab+1,...,ae−1
Input
The input is given in the following format.
n
a0 a1...,an−1
q
b1 e1
b2 e2
:
bq bq
In the first line, n (the number of elements in A) is given. In the second line, ai (each element in A) are given. In the third line, the number of queries q is given and each query is given by two integers biei in the following q lines.
Output
Print all elements of A in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element.