cho.sh
Notes
Loading...

Efficient Hacking

Time limit

5s

Memory limit

256 MB

Problem

A company has N computers and some trust relationships between them. If computer A trusts computer B, then hacking B also makes it possible to hack A.

You can choose one computer to hack first. Write a program that prints every computer number that can lead to hacking the largest possible number of computers.

Input

The first line contains N and M. N is a positive integer at most 10,000, and M is a positive integer at most 100,000.

Each of the next M lines contains two integers A and B, meaning that computer A trusts computer B. The computers are numbered from 1 to N.

Output

Print, in increasing order, all computer numbers from which the largest number of computers can be hacked.