Given two sequences filled with non-negative integers,
Constraints
For all subtasks:
Subtask 1 [20%]
Subtask 2 [80%]
No additional constraints.
Input Specification
The first line consists of two integers
The next two lines consist of
The following
Output Specification
Output the minimized value for each query on
Sample Input
Copy
4 4
7 5 3 5
6 2 9 1
1 2
2 3
3 4
1 2
Sample Output
Copy
7
9
3
7
Comments