Winter Supplies
Hedgehog Alina is experimenting with organizing jars of apples in her warehouse. She has devised a machine that can completely reverse the order of jars within a specified segment. Alina now wants to simulate how this machine operates.
Input Data:
The first line contains the integer N, representing the number of jars Alina has. (N ≤ 10^5
)
The second line lists N integers separated by spaces, indicating the quality of apples in each corresponding jar.
The third line contains the integer M, which is the number of machine queries (M ≤ 5∙10^5
).
Each of the following M lines describes one of two types of queries:
L, R - Reverse the order of jars in the segment from index L to R (inclusive). (0 ≤ L < R ≤ N-1)
X - Retrieve the quality of apples in the jar at position X. (0 ≤ X ≤ N-1)
Output Data:
For each query of the second type, output the quality of apples at the specified position on a separate line.