fun main() = Thread(null, ::abc168d, "", 128 * 1024 * 1024).start()

@OptIn(ExperimentalStdlibApi::class)
fun abc168d() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val abList = List(m) {
        readLine()!!.split(' ').map { it.toInt() - 1 }.let { it[0] to it[1] }
    }

    val graph = Array(n) { Vertex(it) }
    abList.forEach { (a, b) ->
        graph[a].neighbor.add(b)
        graph[b].neighbor.add(a)
    }

    val queue = ArrayDeque(listOf(-1 to 0))
    val indices = IntArray(n) { -1 }
    val visited = mutableSetOf(0)

    while (queue.isNotEmpty()) {
        val (from, to) = queue.removeFirst()
        if (from != -1) indices[to] = from
        graph[to].neighbor.filter { visited.add(it) }.map { to to it }.let { queue.addAll(it) }
    }

    if (indices.drop(1).any { it == -1 }) return println("No")

    val answer = buildString {
        appendln("Yes")
        appendln(indices.drop(1).map { it + 1 }.joinToString(System.lineSeparator()))
    }

    print(answer)
}

private data class Vertex(val index: Int, val neighbor: MutableSet<Int> = mutableSetOf())
