fun main(args: Array<String>) {
    val (n , m) = readLine()!!.split(" ").map { it.toInt() }
    val graph = MutableList<MutableList<Int>>(n){ mutableListOf()}
    for(i in 0 until m){
        val (a , b) = readLine()!!.split(" ").map { it.toInt() }
        graph[a-1].add(b-1)
        graph[b-1].add(a-1)
    }

    val par = MutableList(n){-1}
    val que = java.util.ArrayDeque<Int>()
    par[0] = 0
    que.add(0)
    while(!que.isEmpty()){
        val v = que.pop()

        for(nv in graph[v]){
            if(par[nv] != -1) continue
            par[nv] = v
            que.add(nv)
        }
    }
    println("Yes")
    for(i in 1 until n){
        println(par[i]+1)
    }
}
