N, M = gets.strip.split(/ /).collect{|n| n.to_i}

$branches = {}
$branches_r = {}
(N - 1 + M).times{
	a, b = gets.strip.split(/ /).collect{|n| n.to_i}
	if l = $branches[a]
		l << b
	else
		$branches[a] = [b]
	end
	if l = $branches_r[b]
		l << a
	else
		$branches_r[b] = [a]
	end
}

def find_root
	n = 1
	while l = $branches_r[n]
		n = l[0]
	end
	n
end

def tsort
	l = []
	s = [find_root]
	delete_counts = (N + 1).times.collect{0}
	while n = s.pop
		l << n
		if list = $branches[n]
			list.each{|j|
				if list2 = $branches_r[j]
					delete_counts[j] += 1
					if list2.length - delete_counts[j] == 0
						s << j
					end
				end
			}
		end
	end
	l
end

#p tsort

index_list = []
tsort.each_with_index{|n, i|
	index_list[n] = i
}

(1..N).each{|n|
	if index_list[n] == 0
		puts "0"
	else
		puts $branches_r[n].collect{|x| [index_list[x], x]}.max[1]
	end
}


