import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val graph = Array(n) {
        ArrayList<Int>()
    }
    repeat(m) {
        val (ai, bi) = readLine()!!.split(" ").map { it.toInt()-1 }
        graph[ai].add(bi)
        graph[bi].add(ai)
    }
    val sirube = Array(n) { -1 }
    val queue = ArrayDeque<QueueData>()
    queue.add(QueueData(0, 0))
    while (queue.isNotEmpty()) {
        val now = queue.poll()!!
        if (sirube[now.next] != -1) continue
        sirube[now.next] = now.from
        graph[now.next].forEach { i: Int ->
            queue.add(QueueData(i, now.next))
        }
    }
    println("Yes")
    sirube.drop(1).forEach {
        println(it + 1)
    }
}

data class QueueData(val next: Int, val from: Int)