import collection.mutable.{ArrayBuffer, Queue}

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextInt
  val e = List.fill(m)((sc.nextInt-1, sc.nextInt-1))

  val adj = ArrayBuffer.fill(n)(List[Int]())
  for ((a,b) <- e) {
    adj(a) ::= b
    adj(b) ::= a
  }

  val ans = ArrayBuffer.fill(n)(-1)
  ans(0) = 0
  val queue = Queue(0)
  while (queue.nonEmpty) {
    val u = queue.dequeue()
    for (v <- adj(u) if ans(v) == -1) {
      ans(v) = u + 1
      queue.enqueue(v)
    }
  }

  println("Yes")
  ans.tail.foreach(println)
}