import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val t = Array(n) { mutableListOf<Int>() }
    repeat(m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() - 1 }
        t[a].add(b)
        t[b].add(a)
    }
    val ans = Array(n) { -1 }
    var q = LinkedList<Int>()
    q.add(0)
    ans[0] = 0

    while (q.isNotEmpty()) {
        val nextQ = LinkedList<Int>()
        while (q.isNotEmpty()) {
            val cur = q.poll()
            for (next in t[cur]) {
                if (ans[next] != -1) continue
                ans[next] = cur
                nextQ.add(next)
            }
        }
        q = nextQ
    }
    println("Yes")
    for (i in 1 until n) {
        println(ans[i] + 1)
    }
}
