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
}
rh = (0..N).map{ |m| Hash[rs[m].map{ |n| [n,1] }] }

Root = (1..N).find{ |n| rs[n].size == 0 }
rs[Root] << 0
dp = Array.new(N+1, 0)
dp[Root] = 1

nodes = [Root]
cnt = 0
visited = Array.new(N+1, nil)
#p rh
while n = nodes.pop
  v = dp[n] + 1
  es[n].each{ |m|
    rh[m].delete(n)
    if rh[m].size == 0 && !visited[m]
      visited[m] = 1
      nodes << m
    end
    dp[m] = v if v > dp[m]
    cnt += 1
  }
#  p nodes
end

#p cnt

puts (1..N).map{ |n|
  v = dp[n]
  rs[n].find{ |m| v - dp[m] == 1 }
}