var heyas: List<Heya> = listOf()
var sirubes: MutableList<Int> = listOf<Int>().toMutableList()

fun main(args: Array<String>) {
    val line = readLine()!!.trim()
    val (heyaCount: Int, pathCount: Int) = line.split(" ").map {it.toInt()}

    heyas = (0..heyaCount-1).map {Heya(it + 1)}
    sirubes = (1..heyaCount-1).map {-1}.toMutableList()

    for (i in (0..pathCount-1)) {
        val line2 = readLine()!!.trim()
        val (heya1: Int, heya2: Int) = line2.split(" ").map {it.toInt()}
        heyas[heya1 - 1].paths.add(heya2)
        heyas[heya2 - 1].paths.add(heya1)
    }

    wfs()

    println("Yes")
    for (sirube in sirubes) {
        println(sirube)
    }
}


class Heya(val heyaNo: Int) {
    val paths: MutableList<Int> = mutableListOf()

    fun sirubeIndex(): Int {
        return heyaNo - 2
    }
}

fun wfs() {
    var prevHeyas: MutableList<Heya> = listOf(heyas[0]).toMutableList()

    while (true) {
        if (prevHeyas.isEmpty()) {
            break
        }

        val targetHeyas: List<Heya> = prevHeyas
        prevHeyas = mutableListOf()

        for (targetHeya in targetHeyas) {
            for (nextHeyaNo in targetHeya.paths) {
                if (nextHeyaNo != 1 && sirubes[nextHeyaNo - 2] == -1) {
                    sirubes[nextHeyaNo - 2] = targetHeya.heyaNo
                    prevHeyas.add(heyas[nextHeyaNo - 1])
                }
            }
        }
    }
}
