import java.util.*

fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val conn = Array(n) { mutableListOf<Int>()}

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

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

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

    while (bfs.isNotEmpty()) {
        val idx = bfs.removeFirst()

        conn[idx].forEach { nextIdx ->
            if (ans[nextIdx] != 0) return@forEach
            ans[nextIdx] = idx+1
            bfs.addLast(nextIdx)
        }
    }

    println("Yes")
    println(ans.takeLast(n-1).joinToString(separator = System.lineSeparator()))
}