Efficient Evaluation
문제
Starting from year organizers of all Olympiads in Informatics for high school students decided to conduct their competitions online. An Organization of Online Olympiads (OOO) was created to control and monitor that no one thinks of announcing an onsite competition. Of course, such a powerful and respectful organization needs its own contest managing system. Efficient managers were already hired, sticks and blue tape bought.
In order to increase the efficiency of solutions evaluation a new architecture was introduced. Initially, there are tests located in the testing queue in order from test to test . Scheduling module consequently performs moves. On the -th move it picks a segment of elements of the queue consisting of elements on positions from to inclusive (positions are numbered starting with ) and runs the solution on tests on the positions of (its guaranteed that and are of the same parity). After this is done, all the tests that solution have already been run on are removed from the testing queue and the remaining tests are shifted such that no empty space is left between them. For example, if the testing queue contains tests with initial indices and scheduling module applies operation , , the solution will run on tests at position , and , that have initial indices , and . After this the testing queue will look like .
Your goal is to implement the part of this module that for each of the moves determines the minimum and the maximum initial index of the test that solution was run on at this move.
입력
The first line of the input contains two integers and (, ) — the number of moves that the scheduling module is going to make and the number of tests initially located in the testing queue.
Each of the following lines contains two integers and (1 ≤ l_i ≤ r_i ≤ m) — parameters of the -th move of testing module. It’s guaranteed that before the module applies the -th move there are at least tests in the queue and that and are of the same parity.
출력
For each of the moves of the testing module print two integers — the minimum and the maximum initial index of the test that will be used to test solution (and then removed) during the -th move.
힌트
Consider the first sample.
- Initially, there are all tests from to in the queue, it looks like .
- During the first move tests will be removed. The queue will look like .
- During the second move tests and will be removed and the queue will transform to .
예제
예제 1
2 10 2 8 1 3
2 8 1 5
예제 2
4 6 1 1 1 1 1 1 2 2
1 1 2 2 3 3 5 5