require 'tsort'

n, m = gets.split.map &:to_i

g = Hash[*(0..n-1).map{|i| [i, []]}.flatten(1)]
class << g
    include TSort
    alias :tsort_each_node :each_key
    def tsort_each_child(i, &block)
        self[i].each do |j|
            block.call(j)
        end
    end
end

m.times do
    i, j = gets.split.map &:to_i
    g[i] << j
end

puts g.tsort.reverse