Sparse Table

medium
<a href="https://www.spoj.com/problems/RMQSQ/">https://www.spoj.com/problems/RMQSQ/</a>

Input Format

.

Output Format

.

Constraints

.

Notice

.

Example

Input
3
1 4 1
2
1 1
1 2
Output
4
1
Previous
Create Sorted Array Through Instructions

Related Questions