include

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Short code is cool, reasonable, beautiful, and elegant. You love short code. Hence you want to make your code as short as possible. Several techniques are known to make your code shorter. Today, you focus on "includes" in your code.

There are NN files you must include to your code. The NN files are numbered as 11 through NN. Some of them also include others. If file aa includes file bb and file bb includes file cc, including aa into your code implies including bb and cc into your code. But including cc does not necessarily imply including aa or bb unless cc (indirectly) includes aa or bb.

You are given information about dependencies of NN files, ii-th of which describes file a_ia\_i includes b_ib\_i. From this information, your task is to determine the set of the minimum number of files you have to directly include in order to include all NN files indirectly, and output file numbers in the minimum set in ascending order. If such a set is not uniquely determined, output a set with the minimum sum of the file numbers in a set.

입력

The input consists of a single test case of the following format.

NN MM

a_1a\_1 b_1b\_1

\vdots

a_Ma\_M b_Mb\_M

The first line consists of two integers NN and MM, where NN is the number of files (1N30,0001 ≤ N ≤ 30\\,000) and MM is the number of dependency information (0M5×1050 \le M \le 5 \times 10^5). The following MM lines represents each dependency, the ii-th of which contains two integers a_ia\_i and b_ib\_i, which means file a_ia\_i includes file b_ib\_i (1a_iN1 ≤ a\_i ≤ N, 1b_iN1 ≤ b\_i ≤ N). There is no duplicate dependency information, i.e. a_ia_ja\_i \ne a\_j or b_ib_jb\_i \ne b\_j hold for 1i<jM1 ≤ i < j ≤ M.

출력

Determine the minimum number of files that must be directly included in your code to include all files indirectly, and print file numbers in such a file set in ascending order. If there are multiple sets with the minimum size, output a set with the minimum sum of file numbers.