import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solveMulti(sc: Scanner, pw: java.io.PrintWriter) {
        for (t in 1..sc.next().toInt()) {
            solve(sc, pw)
        }
    }

    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        val way = Array(N) { mutableListOf<Int>() }
        repeat(M) {
            val A = sc.next().toInt() - 1
            val B = sc.next().toInt() - 1
            way[A].add(B)
            way[B].add(A)
        }
        val ans = IntArray(N) { -1 }
        ans[0] = 0
        val q = LinkedList<Int>()
        q.add(0)
        while (q.isNotEmpty()) {
            val i = q.pop()
            way[i].forEach { j ->
                if (ans[j] < 0) {
                    ans[j] = i + 1
                    q.addLast(j)
                }
            }
        }

        if (ans.contains(-1)) {
            pw.println("No")
        } else {
            pw.println("Yes")
            for (i in 1 until N) {
                pw.println(ans[i])
            }
        }
    }
}
