import java.util.*
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val (n, m) = readInts()

    val g = Array(n) { mutableListOf<Int>() }
    val dist = Array(n) { -1 }
    val dir = Array(n) { -1 }
    val q = ArrayDeque<Int>()

    (0 until m).forEach {
        val (aa, bb) = readInts()
        g[aa - 1].add(bb - 1)
        g[bb - 1].add(aa  - 1)
    }

    //g.forEach { println(it) }

    dist[0] = 0
    q.push(0)

    while (!q.isEmpty()) {
        val v = q.removeFirst()

        for (nv in g[v]) {
            if (dist[nv] != -1) continue

            dist[nv] = dist[v] + 1
            dir[nv] = v + 1
            q.addLast(nv)
        }
    }

    println("Yes")
    (1 until n).forEach {
        println(dir[it])
    }
}
