favorite We need a little bit of your help to keep things running, click on this banner to learn more

2013 Петрозаводск, День 6, Август 29, Задачи А - С


As usual winter has surprised the Byteburg city's work crews. There was a blizzard and the main road requires urgent plowing.

The responsibility is on the Department of Disaster Management, equipped with m plows numbered 1 to m. Each plow is associated with a connected fragment of the main road. Two fragments may intersect, however no fragment is contained in another one. The fragments do not have to cover the whole road (the road may consist also of tunnels, which clearly do not need to be plowed).

Unfortunately a strike of all the snow plow men is right about to begin. The head of the Department of Disaster Management convinced only one snow plow man not to take part in the strike. For this reason the only working snow plow man is assigned to handle all the plows. Now it is the time to determine the order in which the plows are going to be used. The Department of Disaster Management ordered the snow plow man to always select a plow, which has the least total length of yet unplowed parts of the fragment associated with it (after plowing a part of the road it is considered to be plowed till the end of the process). In case of a tie the snow plow man should select the plow of minimum number.


The first line contains two integers n and m (1n109, 1m300 000), denoting the length of the road and the number of plows. The following m lines describe subsequent plows, in the order of increasing numbers. The i-th of those lines contains two integers ai, bi (1ai < bin), meaning that the fragment of the road associated with the i-th plow starts at ai and ends at bi. You may assume that ai < ai+1, i.e. the plows are sorted according to the leftmost point of the associated fragment of the road. Furthermore no fragment is contained in a fragment associated with another plow.


Your program should output the numbers of plows in the order they shall be used. The output should consist of m lines, each containing a single integer.


Time limit 1 seconds
Memory limit 128 MiB
Input example #1
15 4
1 6
3 7
6 11
10 14
Output example #1
Source 2013 Petrozavodsk Training Camp, Day 6, August 29, Problem A