DBG = !true
n,m = gets.split.map{|z| z.to_i}
child = Array.new(n)
child.map!{[]}
parent = Array.new(n)
parent.map!{[]}
for i in 0...(n-1+m)
  #a,b = gets.split.map{|z| z.to_i}
  a,b = gets.split
  a = a.to_i - 1
  b = b.to_i - 1
  child[a] << b
  parent[b] << a
end
print parent if DBG

nchild = Array.new(n)
height = Array.new(n,-1)
height_done = Array.new(n,false)
proc = []
for i in 0...n
  nchild[i] = child[i].size
  if child[i].size == 0
    proc << i
    height[i] = 0
  end
end

while !proc.empty?
  i = proc.shift
  for j in parent[i]
    nchild[j] -= 1
    proc << j if nchild[j] == 0  #!height_done[j]
    height_done[j] = true
    height[j] = height[i] + 1 if height[j] < height[i] + 1
  end
end

ht_suf = []
for i in 0...n
  ht_suf << [i, height[i]]
end
ht_suf.sort_by!{|z| z[1]}

realParent = Array.new(n,-1)
for i in 0...n
  j = ht_suf[i][0]
  if parent[j].size == 1
    realParent[j] = parent[j][0]
  elsif parent[j].size > 1
    mnht = 9999999
    mnsuf = -1
    for p in parent[j]
      if height[p] < mnht
        mnht = height[p]
        mnsuf = p
      end
    end
    realParent[j] = mnsuf
  end
  # do nothing if parent.sz == 0 i.e. root -> -1
end

for i in 0...n
  puts "#{realParent[i]+1}"
end
