CAPCITY - Capital City


There are N cities in Flatland connected with M unidirectional roads. The cities are numbered from 1 to N. The Flat Circle of Flatland (FCF) wants to set up a new capital city for his kingdom. For security reasons, the capital must be reachable from all other cities of Flatland. FCF needs the list of all candidate cities. You are the chief programmer at FACM (Flat Association for Computing Machinery) responsible for providing the list to FCF as soon as possible.

Input

The first line of the input file contains two integers: 1 ≤ N ≤ 100,000 and 1 ≤ M ≤ 200,000. Each of the following M lines contains two integers 1 ≤ A, B ≤ N denoting a road from A to B.

Output

The output file contains an integer denoting the number of candidate cities followed by the list of candidate cities in increasing order.

Example

Input:
4 4
1 2
3 2
4 3
2 1

Output:
2
1 2

hide comments
Pratik kumar: 2014-02-04 19:29:55

weak test cases :(

cegprakash: 2014-01-06 12:18:32

There is no test case in which there is no capital city. Add it plz..

Last edit: 2016-07-29 22:20:13
npsabari: 2014-01-14 08:14:39

Simple one, given you know about the maximal connected subgraphs!

Ahmed Salem [mrtempo]: 2012-06-20 19:28:48

What if there were no candidate cities? Should we print zero, and then leave a new line for example?

By the way, I got accepted without handling this case.

jack(chakradarraju): 2011-11-27 03:44:34

very weak test case, my wrong algorithm also got accepted.
RE : why would you submit a wrong algorithm!

Last edit: 2013-06-03 09:43:16

Added by:Narek Saribekyan
Date:2010-06-20
Time limit:1s-4s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS OBJC PERL6 SQLITE VB.NET
Resource:Armenian TST 2010, Round 2