import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val graph = Graph(N)
    repeat(M) {
        val (A, B) = readLine()!!.split(" ").map(String::toInt)
        graph.addEdge(A, B)
        graph.addEdge(B, A)
    }
    val d = graph.bfs(1).drop(2)
    if (d.contains(-1)) {
        println("No")
    } else {
        println("Yes")
        println(d.joinToString("\n"))
    }
}

class Graph(v: Int) {
    private val vec = Array(v + 1) { mutableListOf<Int>() }

    fun addEdge(a: Int, b: Int) {
        vec[a].add(b)
    }

    fun bfs(start: Int): IntArray {
        val que = ArrayDeque<Int>()
        que.addLast(start)
        val d = IntArray(vec.size) { -1 }
        d[start] = start
        while (que.size > 0) {
            val p = que.removeFirst()
            for (next in vec[p]) {
                if (d[next] == -1) {
                    que.addLast(next)
                    d[next] = p
                }
            }
        }
        return d
    }
}