3377. Distribution Center

单点时限: 3.0 sec

内存限制: 256 MB

The factory of the Impractically Complicated Products Corporation has many manufacturing lines and the same number of corresponding storage rooms. The same number of conveyor lanes are laid out in parallel to transfer goods from manufacturing lines directly to the corresponding storage rooms. Now, they plan to install a number of robot arms here and there between pairs of adjacent conveyor lanes so that goods in one of the lanes can be picked up and released down on the other, and also in the opposite way. This should allow mixing up goods from different manufacturing lines to the storage rooms.

Depending on the positions of robot arms, the goods from each of the manufacturing lines can only be delivered to some of the storage rooms. Your task is to nd the number of manufacturing lines from which goods can be transferred to each of the storage rooms, given the number of conveyor lanes and positions of robot arms.

输入格式

The input consists of a single test case, formatted as follows:

  • 1st line:
  • The following lines: .

An integer in the first line is the number of conveyor lanes. The lanes are numbered from to , and two lanes with their numbers differing with 1 are adjacent. All of them start from the position and end at . The other integer is the number of robot arms.

The following lines indicate the positions of the robot arms by two integers and . Here, is the x-coordinate of the -th robot arm, which can pick goods on either the lane or the lane at position , and then release them on the other at the same x-coordinate.

You can assume that positions of no two robot arms have the same x-coordinate, that is, for any .

输出格式

Output integers separated by a space in one line. The -th integer is the number of the manufacturing lines from which the storage room connected to the conveyor lane can accept goods.

样例

Input
4 3
1000 1
2000 2
3000 3
Output
2 3 4 4
Input
4 3
1 1
3 2
2 3
Output
2 4 4 2

3 人解决,3 人已尝试。

3 份提交通过,共有 3 份提交。

6.8 EMB 奖励。

创建: 2 年,1 月前.

修改: 2 年,1 月前.

最后提交: 2 年,1 月前.

来源: ICPC Asia Tsukuba Regional 2016

题目标签