#P7627. [2018年杭电多校]Taotao Picks Apples

[2018年杭电多校]Taotao Picks Apples

Taotao Picks Apples

Problem Description

There is an apple tree in front of Taotao's house. When autumn comes, nn apples on the tree ripen, and Taotao will go to pick these apples. When Taotao picks apples, Taotao scans these apples from the first one to the last one. If the current apple is the first apple, or it is strictly higher than the previously picked one, then Taotao will pick this apple; otherwise, he will not pick. Given the heights of these apples h1,h2,,hnh_1, h_2, \cdots, h_n, you are required to answer some independent queries. Each query is two integers p,qp, q, which asks the number of apples Taotao would pick, if the height of the pp-th apple were qq (instead of hph_p). Can you answer all these queries?

Input

The first line of input is a single line of integer TT (1T10)(1 \leq T \leq 10), the number of test cases. Each test case begins with a line of two integers n,mn, m (1n,m105)(1 \leq n, m \leq 10^5), denoting the number of apples and the number of queries. It is then followed by a single line of nn integers h1,h2,,hnh_1, h_2, \cdots, h_n (1hi109)(1 \leq h_i \leq 10^9), denoting the heights of the apples. The next mm lines give the queries. Each of these mm lines contains two integers pp (1pn)(1 \leq p \leq n) and qq (1q109)(1 \leq q \leq 10^9), as described in the problem statement.

Output

For each query, display the answer in a single line.

Sample Input

1

5 3

1 2 3 4 4

1 5

5 5

2 3

Sample Output

1

5

3

Hint

For the first query, the heights of the apples were 5, 2, 3, 4, 4, so Taotao would only pick the first apple. For the second query, the heights of the apples were 1, 2, 3, 4, 5, so Taotao would pick all these five apples. For the third query, the heights of the apples were 1, 3, 3, 4, 4, so Taotao would pick the first, the second and the fourth apples.

Source

2018 Multi-University Training Contest 8