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

edges=Array.new(N){Array.new}

in_count=Array.new(N,0)

(N-1+M).times do
    a,b=gets.split.map(&:to_i)
    a-=1
    b-=1
    edges[a] << b
    in_count[b]+=1
end

root=in_count.index(0)
data=Array.new(N){Array.new}
ans=Array.new(N)
queue=[]

data[root] << [0,-1] # dist,parent
queue << root

while !queue.empty?
    v=queue.shift
    dist,parent = data[v].max
    ans[v] = parent
    edges[v].each do |vv|
        data[vv] << [dist+1,v]
        queue << vv if data[vv].size==in_count[vv]
    end
end

ans.each do |i|
    puts i+1
end