import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.Queue
import scala.collection.mutable.PriorityQueue

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)


  val V, M = in.next().toInt
  val E = V-1 + M

  val graph = Array.fill[List[Int]](V+1)(Nil) // 隣接リスト

  // input
  for (_ <- 1 to E) {
    val a, b = in.next().toInt
    graph(b) = a :: graph(b)
  }

  //
  val dp = Array.fill[Int](V+1)(-1)
  val ans = new Array[Int](V+1)

  def func(v: Int): Int = {
    if(dp(v) != -1)
      dp(v)
    else {
      if(graph(v).isEmpty) {
        dp(v) = 0
      }
      else {
        for (e <- graph(v)) {
          val now = func(e) + 1
          if(now > dp(v)) {
            dp(v) = now
            ans(v) = e
          }
        }
      }
      dp(v)
    }
  }

  for (i <- 1 to V)
    func(i)

  ans.tail.foreach { pw.println }
  pw.flush()
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}

