QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#18585. DIMIGO Control

统计

In the year 2039, there are $N$ buildings in Dimigo, numbered from $1$ to $N$, and $M$ roads connecting these buildings. There is at most one road directly connecting any two buildings.

One day, a virus spreads through the school, putting all students at risk of infection. To prevent the spread of the virus, you decide to control all roads by performing the following control operation zero or more times:

  • Select a building that is directly connected to at least one uncontrolled road, and then control all roads directly connected to that building.

For the safety of the students, you decide to perform the control operation as many times as possible. Find the sequence in which the control operations should be performed.

Input

The first line contains two space-separated integers, $N$ and $M$, representing the number of buildings and the number of roads, respectively. $(1 \le N \le 10^{5}; 0 \le M \le 10^{5})$

The next $M$ lines each contain two space-separated integers $u$ and $v$, representing the two buildings connected by a road. $(1 \le u, v \le N; u \ne v)$

Output

The first line should output the maximum number of control operations $K$ that can be performed.

The next $K$ lines should each contain the number of the building chosen for the control operation, in the order they are performed.

If there are multiple ways to maximize the number of control operations, you may output any one of them.

Examples

Input 1

3 3
3 2
3 1
2 1

Output 1

2
2
3

Input 2

10 8
4 10
10 7
1 4
8 6
10 1
1 9
7 4
9 5

Output 2

6
7
10
4
5
9
8

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.