import scala.collection.mutable.{Map => MMap, ArrayBuffer}
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, M = in.nextInt
  val map = MMap[Int, ArrayBuffer[Int]]()
  (1 to M).foreach {_ =>
    val a, b = in.nextInt
    map.getOrElseUpdate(a, new ArrayBuffer[Int]()) += b
    map.getOrElseUpdate(b, new ArrayBuffer[Int]()) += a
  }

  val result = new Array[Int](N)
  result(0) = 1

  def dfs(rooms: List[Int]): Unit = {
    if (rooms.nonEmpty) {
      dfs(for {
        r <- rooms
        next <- map(r)
        if result(next - 1) == 0
      } yield {
        result(next - 1) = r
        next
      })
    }
  }
  dfs(List(1))

  if (result.tail.exists(_ == 0)) println("No")
  else {
    println("Yes")
    println(result.tail.mkString("\n"))
  }
}