fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val routes = hashMapOf<Int, MutableSet<Int>>()
    for (i in 0 until m) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        routes.getOrPut(b) { hashSetOf() }.add(a)
        routes.getOrPut(a) { hashSetOf() }.add(b)
    }

    val remainRooms = (2..n).toMutableSet()
    val result = IntArray(n - 1).toMutableList()
    var nextRooms = setOf(1)
    while (true) {
        val next = hashSetOf<Int>()
        for (room in nextRooms) {
            val found = routes[room] ?: continue
            for (f in found) {
                if (remainRooms.contains(f)) {
                    result[f - 2] = room
                    remainRooms.remove(f)
                    next.add(f)
                }
            }
        }
        if (next.isEmpty()) {
            break
        }
        nextRooms = next
    }

    if (remainRooms.isEmpty()) {
        println("Yes")
        for (i in result) {
            println(i)
        }
    } else {
        println("No")
    }
}