N,M=gets.split(" ").map(&:to_i)
A=Array.new(N+M-1,0),B=Array.new(N+M-1,0)
for i in 0..N+M-2
	ta,tb=gets.split(" ").map(&:to_i)
	A[i],B[i]=ta,tb
end
parent=Array.new(N+1).map{[]}
child=Array.new(N+1).map{[]}
for i in 0..N+M-2
	parent[B[i]].push(A[i])
	child[A[i]].push(B[i])
end

root=0
for i in 1..N
	size=parent[i].size
	if size==0
		root=i
	end
end

depth=Array.new(N+1,-1)

v=root
depth[v]=0
queue=[v]
while !queue.empty?

	#queue.each{|c|print c};puts;

	v=queue[0]
	child[v].each{|c|
		if depth[c]<depth[v]+1
			depth[c]=depth[v]+1
		end
		queue.push(c)
	}
	queue=queue.drop(1)
end
trueparent=Array.new(N+1,0)
for i in 0..N+M-2
	if depth[A[i]]+1==depth[B[i]]
		trueparent[B[i]]=A[i]
	end
end
puts trueparent[1..N]

	
		
	