시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 1024 MB 19 7 7 36.842%

## 문제

A network of hyperspace highways is built in the galaxy. Each of the highways is a one-directional corridor which connects two planets. Galactic government wants to find a planet on which a police station will be built.

In order for the police to protect the whole galaxy, it must be possible to travel from the police station to every planet in the galaxy using the hyperspace highways network.

It is not necessary that the police can return back to the police station from any planet using the hyperspace highways. The police needs not to hurry on the way back, and so they can use slower ways than highways.

The government does not know how to deal with finding the suitable planet for the police station; therefore, they ask for your help

You are given the network of one-directional hyperspace highways. Find all planets from which it is possible to reach all other planets in the galaxy using some sequence of highways.

## 입력

The first line of the input contains two integers $N$ a $M$: the number of planets and the number of highways.

Then, $M$ more lines follow. Each contains two integers $A_i$ and $B_i$: the numbers of planets connected by $i$-th highway. Each of the highways is one-directional and can only be used to travel from the planet $A_i$ to the planet $B_i$.

• It holds $1 \leq N, M \leq 10^6$.
• For all $i$it holds $1 \leq A_i, B_i \leq N$ and $A_i \neq B_i$.
• No two highways connect equal planets in the same direction. However, they can connect equal planets in the opposite direction.
• Furthermore, in 30 % of the testcases $N \leq 10^3$ and $M \leq 3 \cdot 10^3$.

## 출력

Output two lines. The first line should contain the total number of planets which are suitable for the police station. The second line should contain a space-separated list of these planets in ascending order.

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

4
1 2 4 5

3 2
1 3
2 3

0