QOJ.ac

QOJ

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

#13515. Byteotian News Agency

Statistics

The Bajtocka Agencja Informacyjna (BAI) has $n$ computers organized in a network. The computers are numbered from 1 to $n$, and the computer numbered 1 is the server. The computers are connected by one-way information channels that connect pairs of computers. The entire network is constructed such that information can be sent from the server—directly or indirectly—to every other computer.

When BAI receives a new message, it is placed on the server and then propagated through the network. The head of the agency is wondering what would happen if one of the computers stopped working completely, for example, if it were destroyed in a terrorist attack. It might turn out that newly received information would not reach some of the other computers because the damaged computer was an unavoidable intermediary. Computers whose failure could lead to such a situation are called critical computers. For example, in the situation shown in the figure below, the critical computers are those numbered 1 and 2—1 is the server, and any information sent from the server to computer 3 must pass through computer 2.

Task

Write a program that:

  • reads the network description from standard input,
  • finds all critical computers,
  • prints the numbers of the critical computers to standard output.

Input

The first line contains two integers, $n$ and $m$, separated by a single space. The number $n$ is the number of computers in the network, $2 \le n \le 5\,000$, and $m$ is the number of information channels, $n - 1 \le m \le 200\,000$. Each of the following $m$ lines describes a single information channel and consists of two integers separated by a single space. These are $a$ and $b$ respectively ($1 \le a, b \le n$, $a \ne b$), which means that the channel transmits information from the computer numbered $a$ to the computer numbered $b$. You may assume that there are no two information channels that start and end at the same points.

Output

The output should consist of two lines. The first line should contain a single integer $k$—the number of critical computers. The second line should contain the numbers of the critical computers separated by single spaces, listed in increasing order.

Examples

Input 1

4 5
1 2
1 4
2 3
3 4
4 2

Output 1

2
1 2

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.