Given and . You are given queries of the form , . For the -th query, you will choose the numbers and () and you want to know what the maximum of the array would be and how many times it would appear in the array if the subarray were censored.
- The subarray of an array is the sequence .
- By censoring a subarray , we mean replacing with for every . For example, if we censor the subarray of the array , we get the array .
Input data
The first line contains two integers, and .
The second line contains an array of natural numbers, representing the array .
The next lines each contain a pair of numbers , .
Output data
The answers to the queries will be printed on lines. The -th line will contain two numbers, representing the answer to the -th query.
Constraints and clarifications
- For points,
Example 1
stdin
9 6
3 2 3 1 6 7 5 7 7
1 2
1 3
3 6
6 9
1 9
2 8
stdout
7 3
7 3
7 2
6 1
0 9
7 1
Explanation
, , and .
For the first query, if we censor the subarray (, ), the resulting array is , with the maximum being and appearing times.
For the third query, if we censor the subarray (, ), the resulting array is , with the maximum being and appearing times.
For the fourth query, if we censor the subarray (, ), the resulting array is , with the maximum being and appearing once.
For the fifth query, if we censor the subarray (, ), the resulting array is , with the maximum being and appearing times.