#2186. Rmq Problem

Rmq Problem

Description

Format

Input

Output

Samples

7 5
0 2 1 0 1 3 2
1 3
2 3
1 4
3 6
2 7
3
0
3
2
4

Limitation