import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val g = Array<MutableList<Int>>(n) { _ -> mutableListOf() }
    (1..m).forEach { _ ->
        val (x, y) = readLine()!!.split(' ').map { it.toInt() - 1 }
        g[x].add(y)
        g[y].add(x)
    }
    var ans = Array(g.size - 1) { _ -> 0 }
    var used = Array(g.size) { _ -> false }
    val que = ArrayDeque<Int>()
    que.add(0)
    used[0] = true
    while (que.isNotEmpty()) {
        val v = que.pop()
        g[v].forEach { to ->
            if (!used[to]) {
                used[to] = true
                ans[to - 1] = v
                que.add(to)
            }
        }
    }
    println("Yes")
    ans.forEach { println(it+1) }
}