시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.6 초 32 MB249807335.784%

문제

A large project is subdivided into N different subprojects. The manager of the project established precedence relations among the subprojects. This means that there are pairs of subprojects u and v such that the completion of the subproject u must be finished before the start of the subproject v. In this case we say that u directly precedes v. We say that u precedes v if u directly precedes v or there is a subproject z such that u precedes z and z precedes v. Any subproject u is considered critical if for each subproject v (other than u) either v precedes u or u precedes v. It is known that the whole project can be completed, e.i., there is no subproject u such that u precedes itself.

Write a program that computes all the critical subprojects.

입력

The first line of the input contains two integers, N and M. N (1 ≤ N ≤ 100000) is the number of the subprojects and M (0 ≤ M ≤ 1000000) is the number of the direct precedence pairs. Subprojects are identified by the numbers 1, . . . , N. Each of the next M lines contains two integers u and v, (1 ≤ u ≠ v ≤ N) a direct precedence pair, that is u directly precedes v.

출력

The first line of the output must contain the number of critical subprojects. The second line contains the identifiers of the critical subprojects in ascending order. The numbers must be separated by a single space. If there is no critical subproject then the first and only line contains the number 0.

예제 입력 1

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

예제 출력 1

2
3 6

힌트