import java.util.Scanner

import scala.collection.mutable

object Main extends App {
  val sc = new Scanner(System.in)
  val N, M = sc.nextInt
  val AB = Array.fill(M)((sc.nextInt, sc.nextInt))

  val G = (AB ++ AB.map(_.swap)).groupBy(_._1).map(x => { x._1 -> x._2.map(_._2) })

  val X = Array.fill(N)(false)
  val Y = Array.fill(N)(0)

  val Q = new mutable.Queue[Int]()
  X(0) = true
  Q += 1
  while (Q.nonEmpty) {
    val v = Q.dequeue
    X(v - 1) = true
    G(v).foreach(i => {
      if (!X(i - 1)) {
        X(i - 1) = true
        Y(i - 1) = v
        Q += i
      }
    })
  }

  println("Yes")
  println(Y.tail.mkString("\n"))
}
