import java.util.ArrayDeque

fun main() {
    val builder = StringBuilder()

    val (n, m) = readInputLine().split(" ").map { it.toInt() }

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

    repeat(m) {
        val (a, b) = readInputLine().split(" ").map { it.toInt() - 1 }
        edges[a].add(b)
        edges[b].add(a)
    }

    val ans = IntArray(n) { -1 }

    val queue = ArrayDeque<Int>()

    for (e in edges[0]) {
        ans[e] = 0
        queue.addLast(e)
    }

    while (queue.isNotEmpty()) {
        val pos = queue.pollFirst()

        for (e in edges[pos]) {
            if (ans[e] == -1) {
                ans[e] = pos
                queue.addLast(e)
            }
        }
    }

    builder.appendln("Yes")

    for (i in 1 until n) {
        builder.appendln(ans[i] + 1)
    }

    print(builder.toString())
}

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