import java.util.ArrayDeque

fun main() {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)

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

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

    val ans = Array(n) { -1 }
    ans[0] = 0

    val que = ArrayDeque<Int>()
    que.addLast(0)

    while (que.isNotEmpty()) {
        val v = que.removeFirst()

        map[v].forEach {
            if (ans[it] != -1) return@forEach

            ans[it] = v + 1
            que.addLast(it)
        }
    }

    println("Yes")
    ans.takeLast(n - 1).forEach {
        println(it)
    }
}