题目描述
Problem Description
A big cleaning event is scheduled at the school where Takahashi attends. The school has $ N $ classrooms, each numbered from $ 1 $ to $ N $ and arranged from left to right.
There are $ M $ students in the school, including Takahashi, and $ M $ cleaning intervals for consecutive classrooms (referred to as cleaning intervals) have already been decided. However, it is not decided who will be responsible for which cleaning interval. Different students are assigned different cleaning intervals, and the assigned student must clean all the classrooms included in it. A single classroom may be included in multiple cleaning intervals.
Takahashi realized that he has a date with a girl on the day of the big cleaning. Since he doesn't know what would happen if he skipped the date, he decided to skip the cleaning. As mentioned earlier, some classrooms may be included in multiple cleaning intervals, so Takahashi realized that if someone else cleans all the classrooms in his assigned interval, he can get away with skipping the cleaning without getting caught. If there is any classroom that is not cleaned, skipping the cleaning will be revealed.
Your task is to help Takahashi by telling him all the cleaning intervals he can skip without getting caught.
Note that all the students in the school, except Takahashi, are very diligent, so you can assume that no one else will skip the cleaning.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ s_1 $ $ t_1 $ $ s_2 $ $ t_2 $ : $ s_M $ $ t_M $
- The first line contains two integers $N\ (1\ ≦\ N\ ≦\ 300,000)$ representing the number of classrooms in the school, and $M(1\ ≦\ M\ ≦\ 100,000)$ representing the number of students.
- The following $ M $ lines contain the $ M $ cleaning intervals. The $ i(1≦i≦M) $th line contains two integers $ s_i,t_i(1≦s_i≦t_i≦N) $ representing the $ i $th cleaning interval. This means that if a student is assigned this interval, they must clean all classrooms $ x $ that satisfy $ s_i≦x≦t_i $.
- The same interval may be given multiple times.
- It is guaranteed that any classroom is included in at least one cleaning interval.
Output Format
Output to the standard output.
The first line should contain the number $ k $ of cleaning intervals that Takahashi can skip without getting caught.
The following $ k $ lines should contain the numbers of the cleaning intervals that Takahashi can skip without getting caught, in ascending order, each separated by a newline. Ensure there is a newline at the end of the last line.
Sample Input and Output
Sample Input #1
10 5
1 4
5 5
6 8
9 10
5 6
Sample Output #1
2
2
5
Sample Input #2
3 6
1 1
1 1
2 2
2 2
3 3
3 3
Sample Output #2
6
1
2
3
4
5
6
Sample Input #3
10 3
1 4
2 6
6 10
Sample Output #3
0
Notes/Hints
Partial Points
In addition to the above constraints, if your solution correctly handles the following additional constraint, you will be awarded $ 30 $ points:
- For any classroom $i\ (1≦i≦N)$, the number of cleaning intervals that include that classroom is at most $ 2 $.
Sample Explanation 1
If Takahashi is assigned the $ 2 $nd or $ 5 $th cleaning interval, he can skip without getting caught. Specifically:
- If assigned the $ 2 $nd interval, the $ 5 $th interval includes classroom $ 5 $, so he won't get caught.
- If assigned the $ 5 $th interval, the $ 2 $nd interval includes classroom $ 5 $, and the $ 3 $rd interval includes classroom $ 6 $, so he won't get caught.
On the other hand, if Takahashi is assigned the $ 1 $st, $ 3 $rd, or $ 4 $th interval, skipping will get him caught. Specifically:
- If assigned the $ 1 $st interval, classrooms $ 1, 2, 3, 4 $ will not be cleaned, so he will get caught.
- If assigned the $ 3 $rd interval, classrooms $ 7, 8 $ will not be cleaned, so he will get caught.
- If assigned the $ 4 $th interval, classrooms $ 9, 10 $ will not be cleaned, so he will get caught.
Sample Explanation 2
Takahashi can skip any cleaning interval without getting caught.
Sample Explanation 3
There may be no cleaning interval that Takahashi can skip without getting caught.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分