Permutation
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 122.174 megabytes
You are given a permutation of first n positive integers in array. Print the smallest index of array that contains the number in the range from a to b (inclusive).
Input
First line contains two integers n and q (n, q ≤ 10^5
) separated by a space. Second line contains a permutation of n integers (from 1 to n in any order). Then q lines follow: each line contains two integers a and b (a ≤ b ≤ 10^5
) separated by space.
Output
Print exactly q lines each containing the answer.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 48%