#P1332G. No Monotone Triples
No Monotone Triples
No submission language available for this problem.
Description
Given a sequence of integers of length , a tuple is called monotone triples if
- ;
- or is satisfied.
For example, , then is monotone triples for sequence while is not.
Bob is given a sequence of integers of length in a math exam. The exams itself contains questions of form , for each of them he is asked to find any subsequence with size greater than (i.e. ) of sequence .
Recall that an sequence is a subsequence of sequence if can be obtained by deletion of several (possibly zero, or all) elements.
However, he hates monotone stuff, and he wants to find a subsequence free from monotone triples. Besides, he wants to find one subsequence with the largest length among all subsequences free from monotone triples for every query.
Please help Bob find out subsequences meeting the above constraints.
The first line contains two integers , (, ) — the length of sequence and the number of queries.
The second line contains integers (), representing the sequence .
Then each of the following lines contains two integers , (, ).
For each query, output if there is no subsequence satisfying the constraints mentioned in the legend. You can print the empty line after but that's not mandatory.
Otherwise, output one integer () denoting the length of sequence , then output integers () satisfying that for .
If there are multiple answers with the maximum length, print any of them.
Input
The first line contains two integers , (, ) — the length of sequence and the number of queries.
The second line contains integers (), representing the sequence .
Then each of the following lines contains two integers , (, ).
Output
For each query, output if there is no subsequence satisfying the constraints mentioned in the legend. You can print the empty line after but that's not mandatory.
Otherwise, output one integer () denoting the length of sequence , then output integers () satisfying that for .
If there are multiple answers with the maximum length, print any of them.
Samples
Note
For the first query, the given sequence itself is monotone triples free.
For the second query, it can be shown that there is no subsequence with length greater than such that is monotone triples free.