QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 10

#6087. Blizzard

Statistics

As usual, winter has caught the road crews by surprise. A blizzard is raging in Byteland, and the main road of Byteland urgently needs to be cleared of snow.

The crisis management team is responsible for the order and has $ m $ snowplows at its disposal, numbered from 1 to $ m $. Each plow is assigned a specific contiguous segment of the road to clear. Two segments may overlap, but no segment is entirely contained within another. The segments do not have to cover the entire length of the road (some parts of the road may run through tunnels and do not require clearing).

Unfortunately, a road workers' strike has just begun. The management of the crisis team has managed to convince only one plow operator to work, who has been entrusted with operating all the machines. Now, the order in which the plows are deployed must be determined. It has been ordered that each time, the worker will choose the plow that has the least amount of its assigned road segment left to clear (it is sufficient for each piece of the road to be cleared once, so a plow does not need to clear those parts that have already been cleared by other plows). In the event of a tie, the worker will choose the plow with the lower number.

Input

The first line of input contains two integers $ n $ and $ m $ ($ 1 \le n \le 10^{9} $, $ 1 \le m \le 300\,000 $), representing the length of the road and the number of plows. The next $ m $ lines describe the subsequent plows, with increasing numbers. The description of the $ i $-th plow consists of two integers $ a_{i} $, $ b_{i} $ ($ 1 \le a_{i} < b_{i} \le n $), representing the beginning and end of the road segment assigned to the $ i $-th plow. You may assume that $ a_{i} < a_{i+1} $, i.e., the plows are sorted by the beginning of their assigned road segment. Furthermore, no segment is entirely contained within another.

Output

Your program should output the numbers of the plows in the order they clear the road. The output should consist of $ m $ lines, each containing a single integer.

Examples

Input 1

15 4
1 6
3 7
6 11
10 14

Output 1

2
1
3
4

Note

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.