N,M = gets.split.map(&:to_i)
es = (0..N).map{ [] }
rs = (0..N).map{ [] }
(N+M-1).times{
  a,b = gets.split.map(&:to_i)
  es[a] << b
  rs[b] << a
}

Root = (1..N).find{ |n| rs[n].size == 0 }

def topological_sort(node_num, edges, roots)
  ns = Array.new(node_num+1,0)
  edges.each{ |h| h.each{ |m| ns[m] += 1 } }
  nodes = roots.map{ |d| d }
  sorted = []
  while n = nodes.pop
    sorted << n
    edges[n].each{ |m|
      ns[m] -= 1
      if ns[m] == 0
        nodes << m
      end
    }
  end
  sorted
end

sorted = topological_sort(N, es, [Root])
dp = Array.new(N+1,0)
dp[sorted[0]] = 1
rs[Root] << 0
sorted.each{ |n|
  es[n].each{ |m|
    dp[m] = dp[n] + 1 if dp[n] >= dp[m]
  }
}
puts (1..N).map{ |m|
  rs[m].find{ |n| dp[m] == dp[n] + 1 }
}