object Main extends App {
  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val inEdgeCount = Array.tabulate(n){_ ⇒ 0}
  val edges = Array.tabulate(n){_ ⇒ Nil: List[Int]}
  for (_ ← 1 until n + m){
    val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)
    inEdgeCount(b) += 1
    edges(a) ::= b
  }
  var current = List(inEdgeCount.indexWhere(_ == 0))
  val prev = Array.tabulate(n){_ ⇒ 0}
  while (current.nonEmpty){
    var next = Nil: List[Int]
    for (c ← current; e ← edges(c)) {
      inEdgeCount(e) -= 1
      if (inEdgeCount(e) == 0) {
        next ::= e
        prev(e) = c + 1
      }
    }
    current = next
  }
  println(prev.mkString("\n"))
}