import java.util.concurrent.LinkedBlockingDeque

fun main() {
    data class Pos(val toRoom: Int, val room: Int)
    val (n, m) = readLine()?.split(" ")?.map(String::toInt) ?: return

    val routes = Array(n) { mutableListOf<Int>() }
    repeat(m) {
        val (a, b) = readLine()?.split(" ")?.map(String::toInt)!!
        routes[a - 1].add(b - 1)
        routes[b - 1].add(a - 1)
    }
    val signpost = Array(n) { -1 }
    val already = Array(n) { false }
    already[0] = true
    var remain = n
    val queue = LinkedBlockingDeque<Int>()
    routes.first().forEach {
        already[it] = true
        signpost[it] = 0
        remain--
        queue.offer(it)
    }
    while (queue.isNotEmpty()) {
        val p = queue.poll()
        val aisles = routes[p]
        aisles.forEach {
            if (signpost[it] == -1) {
                signpost[it] = p
                remain--
            }
            if (!already[it]) {
                already[it] = true
                queue.offer(it)
            }
        }
    }
    if (signpost.any { remain > 0 }) {
        println("No")
        return
    }
    buildString {
        appendln("Yes")
        1.until(n).forEach {
            appendln(signpost[it] + 1)
        }
    }.let {
        println(it)
    }
}