QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#10500. Two paths

Estadísticas

In Byteotia, cities are connected by one-way roads. The road network there is quite specific: for any city, if we leave it via a certain road, we cannot return to it by moving along the Byteotian roads in accordance with their direction. In other words, we can imagine the road network of Byteotia as a directed acyclic graph.

The specific nature of the Byteotian road network creates certain problems. Some cities cannot be reached even from the country's capital. The problem is even greater because traffic on individual roads is often suspended due to modernization. Bajtazar, who lives in the capital, often travels to various cities in Byteotia. He would like to know for each of them whether it is possible to reach it from the capital via two paths that do not share any common roads. If this is the case, or if the destination city is the capital, then Bajtazar knows that his journey to that city will proceed without problems, even if one of the roads (or many roads on one of the paths) were under renovation.

Help Bajtazar determine the set of cities to which he will be able to travel from the capital without problems.

Input

The first line of input contains two natural numbers $n$ and $m$ ($1 \le n \le 200\,000$, $1 \le m \le 500\,000$), representing the number of cities and the number of roads between them, respectively. The cities are numbered from $1$ to $n$. The capital of Byteotia has the number $1$.

The next $m$ lines contain the description of the roads. The $i$-th of these lines contains two integers $u_i$ and $v_i$ ($1 \le u_i, v_i \le n$, $u_i \neq v_i$), meaning that the $i$-th one-way road leads from city $u_i$ to city $v_i$.

Output

In the first line of output, print the number of cities to which Bajtazar will be able to travel without problems. In the second line of output, there should be the numbers of these cities in increasing order, separated by single spaces.

Examples

Input 1

7 9
1 2
1 3
3 4
4 5
2 4
2 5
5 6
5 7
5 7

Output 1

4
1 4 5 7

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.