Just h-index
题号:NC52893
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 128 M,其他语言256 M
Special Judge, 64bit IO Format: %lld

题目描述

The h-index of an author is the largest h where he has at least h papers with citations not less than h.
Bobo has published n papers with citations respectively.
One day, he raises q questions. The i-th question is described by two integers l_i and r_i, asking the h-index of Bobo if has *only* published papers with citations .

输入描述:

The input consists of several test cases and is terminated by end-of-file.
The first line of each test case contains two integers n and q.
The second line contains n integers .
The i-th of last q lines contains two integers l_i and r_i.

输出描述:

For each question, print an integer which denotes the answer.
示例1

输入

复制
5 3
1 5 3 2 1
1 3
2 4
1 5
5 1
1 2 3 4 5
1 5

输出

复制
2
2
2
3

备注:

* 
*
*
* The sum of n does not exceed 250,000.
* The sum of q does not exceed 250,000.