
import java.util.*
import kotlin.collections.HashMap
import kotlin.collections.HashSet


fun main(args: Array<String>) {
    val (n, k) = getInts()
    val s = HashMap<Int, MutableSet<Int>>()

    repeat(k) {
        val (a, b) = getInts()
        if (s[a] == null) s[a] = HashSet()
        if (s[b] == null) s[b] = HashSet()
        s[a]!!.add(b)
        s[b]!!.add(a)
    }
    val out = IntArray(n + 1) { 0 }

    val q: Queue<Int> = LinkedList()
    q.add(1)
    var c = 0
    while (c < n - 1 && q.isNotEmpty()) {
        val now = q.poll()
        s[now]?.forEach {
            if (out[it] == 0 && it != 1) {
                out[it] = now
                c++
                q.add(it)
            }
        }
    }

    if (c == n - 1) {
        println("Yes")
        println(out.drop(2).joinToString("\n"))
    } else {
        println("No")
    }
}


fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }
