n,m=gets.split.map(&:to_i)
kiarray=Array.new(n).map{Array.new(2).map{Array.new}}
(n-1+m).times{
    parent,child=gets.split.map(&:to_i)
    kiarray[parent-1][1].push(child)
    kiarray[child-1][0].push(parent)
}

root=0
n.times{|k|
    if kiarray[k][0]==[]
        root=k+1
        break
    end
}

nisecount=0
que=[root]

while nisecount<m
    shift = que.shift
   children=kiarray[shift-1][1]

   ll=children.length
   index=0
   ll.times{
        value=children[index]
        if !kiarray[value-1][0][1]
            que.push(value)
            index+=1
         else
            nisecount+=1
            kiarray[shift-1][1].delete(value)
            kiarray[value-1][0].delete(shift)
        end
   }
end

kiarray.map.with_index{|value,index|
    if  index==root-1
        puts 0
    else
        puts value[0][0]
    end
}