N,M,*rest = $stdin.read.split.map(&:to_i)

bs = []
nodes = {}
rest.each_slice(2) do |a,b|
  nodes[a] ||= []
  nodes[a] << b
  bs << b
end

targets = (1..N).to_a - bs
answers = {targets.first => 0}

until targets.empty?
  next_targets = []
  targets.each do |t|
    children = nodes[t]
    next unless children
    next_targets += children
    children.each do |x|
      answers[x] = t
    end
  end
  targets = next_targets
end

as = Array.new(N+1)
answers.each do |k,v|
  as[k-1] = v
end
puts as.join("\n")