if !ENV['RUBY_THREAD_VM_STACK_SIZE']
  exec({'RUBY_THREAD_VM_STACK_SIZE'=>'1000000000'}, '/usr/bin/ruby', $0)
else
  require 'tsort'

  N, M = gets.split.map(&:to_i)

  g = Hash.new
  (1..N).each do |i|
    g[i] = []
  end

  (N - 1 + M).times do
    from, to = gets.split.map(&:to_i)
    g[from] << to
  end

  each_node = -> (&b) { g.each_key(&b) }
  each_child = -> (n, &b) { g[n].each(&b) }
  order = TSort.tsort(each_node, each_child).reverse

  parent = Array.new(N + 1, 0)
  parent[order.first] = 0

  order.each do |i|
    g[i].each do |to|
      parent[to] = i
    end
  end

  puts [*1..N].map { |i| parent[i] }
end
