require "tsort"

class Graph
  include TSort
  attr_accessor :g, :n

  def initialize(n)
    @n = n
    @g = Array.new(n){ [] }
  end

  def [](i); g[i]; end
  def []=(i,v); g[i]=v; end

  def tsort_each_node
    n.times do |i|
      yield i
    end
  end

  def tsort_each_child(i)
    g[i].each do |j|
      yield j
    end
  end
end

n,m = gets.split.map(&:to_i)
g = Graph.new(n+1)
(n+m-1).times.each do
  a,b = gets.split.map(&:to_i)
  g[b] << a
end
ord = g.tsort
inv = ord.zip(0..).sort

ans = Array.new(n+1) do |i|
  next 0 if i.zero?
  candi = g[i].map{|i|inv[i]}.sort_by{|e|-e[1]}
  next 0 if candi.empty?
  candi[0][0]
end
puts ans[1..].join("\n")
