require 'tsort'

class Hash
  include TSort
  alias tsort_each_node each_key
  def tsort_each_child(node, &block)
    fetch(node).each(&block)
  end
end

def dfs(e,reve)
	stack = []
	reve.select{|k,v| v.size == 0}.each{|k,v|
		stack << k
	}
	# stack = reve.select{|a| a[1].size == 0}.to_a # not stack
	revnum = [0] + reve.map{|k,v| v.size} # incoming nodes numbers
	# p revnum
	# p stack
	result = []
	while(!stack.empty?)
		v = stack.pop
		result.push(v)
		# p "e #{e}"
		# p "v #{v}"
		# p "e[v] #{e[v]}"
		chs = e[v]
		chs.each{|ch|
			# p "ch #{ch}"
			# p "revnum[ch] #{revnum[ch]}"
			revnum[ch] -= 1
			# p "revnum[ch] reduced to #{revnum[ch]}"
			if(revnum[ch] == 0)
				result.push(ch)
				# p "children of #{ch} pushed"
				# p "#{e[ch]}"
				# p "stack #{stack}"
				stack += e[ch]
			end
		}
	end
	result
end

N,M=gets.split(" ").map{|i| i.to_i}
h = {}
revh = {} # child -> parents
for i in 0..(N-1)
	h[i+1] = []
	revh[i+1] = []
end
for i in 0..(N-2+M)
	a,b = gets.split(" ").map{|i| i.to_i}
	h[a].nil? ? h[a] = [b] : h[a] << b
	revh[b].nil? ? revh[b] = [a] : revh[b] << a
end
# p h
# p revh
tsort = dfs(h,revh)
# p tsort

node_level = Array.new(N+1) { |i| 0 }
parent = Array.new(N+1) { |i| 0 }
for i in 0..(N-1)
	node = tsort[i]
	h[node].each{|c|
		node_level[c] = node_level[node] + 1
		parent[c] = node
	}
end
# p node_level 
# p parent
for i in 1..(N)
	puts parent[i]
end
