require 'set'
require 'tsort'

n, m = gets.split.map(&:to_i)

g = {}
g_inv = {}

(0..n-1).each do |i|
	g[i] = Set.new
	g_inv[i] = Set.new
end

roots = Set[*(0..n-1).to_a]
m.times do
	i, j = gets.split.map(&:to_i)
	roots.delete(j)
	g[i] << j
	g_inv[j] << i
end

class Hash
	include TSort
	alias :tsort_each_node :each_key
	def tsort_each_child(u)
		self[u].each do |v|
			yield(v)
		end
	end
end

ord = g.tsort

flip = {}
roots.each do |r0|
	rest_roots = roots - [r0]
	f = 0
	reachable = Set[r0]

	r = r0
	until rest_roots.empty?
		stack = [r]	
		until stack.empty?
			u = stack.pop
			g[u].each do |v|
				next if reachable.include?(v)
				stack << v
				reachable << v
			end
		end

		dist = Hash.new(Float::INFINITY)
		reachable.each do |v|
			dist[v] = 0
		end
		
		ord.each do |u|
			d = dist[u] + 1
			g_inv[u].each do |v|
				dist[v] = d if d < dist[v]
			end
		end

		r = rest_roots.min_by {|u| dist[u]}
		f += dist[r]
		rest_roots.delete(r)
	end

	flip[r0] = f
end

min_f = flip.values.min
min_by = (0..n-1).select {|u| flip[u] == min_f}
puts [min_by.size, min_f] * ' '
puts min_by * ' '