fun main(){
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val rennrakuList = MutableList(m){ MutableList(2) { 0 } }
    for (i in 0 until m){
        rennrakuList[i] = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
        if (rennrakuList[i][0] > rennrakuList[i][1]) {
            var tmp = rennrakuList[i][0]
            rennrakuList[i][0] = rennrakuList[i][1]
            rennrakuList[i][1] = tmp
        }
    }
    val tunagariList = MutableList(n){ mutableListOf<Int>() }//下のforとあわせてこのListにどの洞窟とどの洞窟がつながってるか書いておく
    for (i in 0 until m){
        tunagariList[rennrakuList[i][0] - 1].plusAssign(rennrakuList[i][1])
        tunagariList[rennrakuList[i][1] - 1].plusAssign(rennrakuList[i][0])
    }


    val seen = MutableList(n){ 0 }
    var todo = mutableListOf<Int>()

    var count = 0//何回再帰したか数える
    tailrec fun myBfs(theNum: Int){

        count++
        val tunagarukazu = tunagariList[theNum-1].size

        for (i in 0 until tunagarukazu){
            if (seen[tunagariList[theNum-1][i] - 1] == 0){
                seen[tunagariList[theNum-1][i] - 1] = theNum
                todo.add(tunagariList[theNum-1][i])
            }
        }

        if (count != n){
            myBfs(todo[count-1])
        } else {
            return
        }
    }



    myBfs(1)

    println("Yes")
    for (i in 1 until n){
        println(seen[i])
    }
}