Blizzard
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.
Input
The first line contains two integers n and m (1 ≤ n ≤ 10^9
, 1 ≤ m ≤ 300 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 a[i]
, b[i]
(1 ≤ a[i]
< b[i]
≤ n), meaning that the fragment of the road associated with the i-th plow starts at a[i]
and ends at b[i]
. You may assume that a[i]
< a[i+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.
Output
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.