#D746. Reverse
Reverse
Reverse
Write a program which reads a sequence of integers and reverse specified elements by a list of the following operation:
- reverse(): reverse the order of
Constraints
Input
The input is given in the following format.
:
In the first line, (the number of elements in ) is given. In the second line, (each element in ) are given. In the third line, the number of queries is given and each query is given by two integers in the following lines.
Output
Print all elements of 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.
Example
Input
8 1 2 3 4 5 6 7 8 2 1 6 3 8
Output
1 6 5 8 7 2 3 4
inputFormat
Input
The input is given in the following format.
:
In the first line, (the number of elements in ) is given. In the second line, (each element in ) are given. In the third line, the number of queries is given and each query is given by two integers in the following lines.
outputFormat
Output
Print all elements of 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.
Example
Input
8 1 2 3 4 5 6 7 8 2 1 6 3 8
Output
1 6 5 8 7 2 3 4
样例
8
1 2 3 4 5 6 7 8
2
1 6
3 8
1 6 5 8 7 2 3 4