require 'pp'
$works, $seiyaku = gets.split.map(&:to_i)

$conditions = []
for i in 1..$works do
	before,after= gets.split.map(&:to_i)
	condition = {before:before,after:after}
	$conditions.push(condition)
end

$node = []
 
def search(condition)
	if $node.size == $works then
		return
	elsif $node.include?(condition[:before]) then
		for k in 1..$node.size do
			if $node[k-1] == condition[:before] then
				$node.insert(k, condition[:after])
			end
		end
	elsif $node.include?(condition[:after]) then
		for m in 1..$node.size do
			if $node[m-1] == condition[:after] then
				$node.insert(m, condition[:before])
			end
		end
	else
		$node.push(condition[:before])
		$node.push(condition[:after])
	end
	return
end

for j in 1..$works do
	search($conditions[j-1])
end

for l in 1..$works do
	puts $node[l-1]
end