import scala.collection.mutable

object Main extends App{
  val line = io.StdIn.readLine.split(' ').map(_.toInt)
  val N = line.head
  val M = line.last

  case class Room (var distance:Int = N + 1, connected: mutable.Set[Int] = mutable.Set[Int]())
  var rooms = (1 to N).map(x => {x -> Room()}).toMap

  for(i <- 1 to M){
    val s = io.StdIn.readLine.split(' ').map(_.toInt).sorted
    val a = s.head
    val b = s.last
    rooms(a).connected += b
    rooms(b).connected += a
  }

  def setDistance(i:Int, d: Int): Unit = {
    if(d < rooms(i).distance){
      rooms(i).distance = d
      for(next <- rooms(i).connected){
        setDistance(next, d+1)
      }
    }
  }

  setDistance(1, 0)

  if(rooms.values.filter(_.distance == N+1).isEmpty){
    println("Yes")
    for(i <- 2 to N){
      val nextRooms = rooms(i).connected.map(x => (x, rooms(x).distance))
      println(nextRooms.minBy(_._2)._1)
    }
  }else println("No")
  /*
  for(i <- 1 to N){
    print(i + " " + rooms(i).distance + " ")
    println(rooms(i).connected)
  }
  */
}