table = Array.new(100001).map{[]}
n,m = gets.split(" ").map{|d| d.to_i}

m.times do |i|
	a,b = gets.split(" ").map{|d| d.to_i}
	table[a] << "#{i+1},#{b}"
end

target = []
1.upto(n) do |i|
	q = []
	table[i].each do |t|
		idx = t.split(",").map{|d| d.to_i}[0]
		q << t
		while q.empty? == false
			z, b = q.shift.split(",").map{|d| d.to_i}
			t2 = table[b]
#			p [idx, t2, t2.length]
			if t2.length == 1
				q << t2[0]
			elsif t2.length > 1
#				p [idx, t2, t2.length]
				target << idx
				break
			end
		end
	end
end

#p target
target.uniq!.sort.each{|i| puts i}
puts -1 if target.length == 0