Dengue, the talk of the town of Dhaka this year. So many people suffered from dengue fever and a number of people died. In this problem, you are going to process some queries with some given information about the affects of dengue.
There are most dengue affected areas in Bangladesh. These are numbered from 1 to . The affect value of the -th area is . Now, you need to process queries.
A query is defined as L R P Q
: You need to print,
Count of areas numbered from to where dengue affect is at least and at most .
Minimum affect value which is present in area to and between to . If there is no such value, print -1.
Maximum affect value which is present in area to and between to . If there is no such value, print -1.
The first line of input will contain two integers and ().
The next line will contain integers denoting , , ..., ().
The next lines will be followed by four integer , , and (, ).
For each query, output three integers as defined in the problem statement.
Input | Output |
---|---|
3 2 1 2 3 1 3 1 3 1 3 4 5 | 3 1 3 0 -1 -1 |
In the first query, there are three affect values between and in area to . So the first integer of the output is 3. Among these, the minimum is 1 and the maximum is 3, so the next two integers of the output is 1 and 2 respectively. In the second query, there is no affect value between and in area to . |