fun main() {
    val (n, m) = next2Int()
    val michi = Array(n + 1) { arrayListOf<Int>() }
    repeat(m) {
        val (a, b) = next2Int()
        michi[a].add(b)
        michi[b].add(a)
    }
    val signs = IntArray(n + 1)
    signs[0] = 1
    signs[1] = 1
    var nextList = arrayListOf<Pair<Int, Int>>()
    for (next in michi[1]) {
        nextList.add(1 to next)
    }
    while (nextList.isNotEmpty()) {
        val tmpList = arrayListOf<Pair<Int, Int>>()
        for ((current, next) in nextList) {
            if (signs[next] == 0) {
                signs[next] = current
                for (tmp in michi[next]) {
                    tmpList.add(next to tmp)
                }
            }
        }
        nextList = tmpList
    }
    if (signs.all { it > 0 }) {
        printString {
            appendln("Yes")
            for (i in 2..n) {
                appendln(signs[i])
            }

        }
    } else {
        println("No")
    }
}

val sc = java.util.Scanner(System.`in`)
fun next(): String = sc.next()
fun nextInt() = sc.nextInt()
fun next2Int() = Pair(nextInt(), nextInt())
fun next3Int() = Triple(nextInt(), nextInt(), nextInt())
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLong() = sc.nextLong()
fun nextLine(): String = sc.nextLine()
fun nextList() = nextLine().split(" ")
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")
fun printString(action: StringBuilder.() -> Unit) = println(buildString(action))