Gats and the Two Tempting Cushions
Gats the kitten is walking on a row of cushions. The cushions are numbered from left to right, and cushion has softness .
When Gats is on cushion , he looks only to the right. Let be the smallest index such that and , if such an index exists. Let be the smallest index such that and , if such an index exists.
Gats chooses his next pounce as follows:
- If neither nor exists, Gats cannot pounce and stays on cushion .
- If exactly one of and exists, Gats pounces to that cushion.
A pounce is called fluffy if the destination cushion has greater softness than the starting cushion.
You are given independent queries. In the -th query, Gats starts on cushion and tries to make scheduled pounces. If he reaches a cushion from which he cannot pounce, he remains there for all remaining scheduled pounces. For each query, report his final cushion and the number of fluffy pounces he actually made.
Input
The first line contains two integers and (), the number of cushions and the number of queries.
Output
Print lines. On the -th line (), print two integers and , separated by one space. Here is the cushion where Gats is after the query finishes, and is the number of fluffy pounces actually made during that query.
Samples
Sample 1
Input
7 5 4 7 2 6 5 9 1 5 2 4 3 2 1 1 5 7 10
Output
7 1 7 1 6 1 7 0 7 0
For the query with and , the visited cushions are . Only the pounce lands on a cushion with greater softness, so the printed values are and .