fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toInt() }

    val edges = Array(N) { mutableListOf<Int>() }
    val revEdges = Array(N) { mutableListOf<Int>()}

    repeat(N + M - 1) {
        val (A, B) = readInputLine().split(" ").map { it.toInt() - 1 }
        edges[A].add(B)
        revEdges[B].add(A)
    }

    val topologicalSorted = IntArray(N) { -1 }
    var current = N - 1

    fun topologicalSort(node: Int) {
        for (c in edges[node]) {
            if (topologicalSorted[c] != -1) {
                continue
            }
            topologicalSort(c)
        }
        topologicalSorted[node] = current
        current--
    }

    repeat(N) {
        if (topologicalSorted[it] == -1) {
            topologicalSort(it)
        }
    }

    repeat(N) {
        if (topologicalSorted[it] == 0) {
            println(0)
        } else {
            var minNode = -1
            var minOrder = -1
            for (r in revEdges[it]) {
                if (topologicalSorted[r] > minOrder) {
                    minOrder = topologicalSorted[r]
                    minNode = r
                }
            }
            println(minNode + 1)
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}
