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) // 隣接リスト
  val indegree = new Array[Int](V+1) // 入次数

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

  var deg0 = new scala.collection.mutable.Stack[Int]
  for (i <- 1 to V) {
    if(indegree(i) == 0)
      deg0.push(i)
  }

  var res = List[Int]()
  while(!deg0.isEmpty) {
    val node = deg0.pop()
    res = node :: res
    for (e <- graph(node)) {
      indegree(e) -= 1 // 隣接する頂点の入次数をマイナス1
      if (indegree(e) == 0) // これによって入次数が0になればstに追加
        deg0.push(e)
    }
  }

  res = res.reverse
  

  //
  val root = res.head
  val ans = new Array[Int](V+1)

  for(node <- res) {
    for(e <- graph(node)) {
      ans(e) = node
    }
  }

  for (i <- 1 to V) {
    if(i == root)
      println(0)
    else
      println(ans(i))
  }
}


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()
  }
}

