import java.util.*
 
fun main(args: Array<String>) {
  val (N, M) = readInts()
  val edges = Array(N + 1) { mutableListOf<Int>() }
  repeat(M) {
    val (A, B) = readInts()
    edges[A].add(B)
    edges[B].add(A)
  }
 
  val memo = Array(N + 1) { -1 }
  memo[1] = 1
 
  val queue = ArrayDeque<Int>()
  queue.add(1)
  while (true) {
    if (queue.isEmpty()) break
    val n = queue.first
    queue.removeFirst()
    val e = edges[n]
    e.forEach {
      if (memo[it] == -1) {
        memo[it] = n
        queue.addLast(it)
      }
    }
  }
 
  // println(if (memo.count { it == -1 } <= 1) "Yes" else "No")
  println("Yes")
  print(buildString {
    for (i in 2 until memo.size) {
      appendln(memo[i])
    }
  })
}
 
fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }