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)(-1)

  def BFS(x: Int): Unit = {
    val Q = new mutable.Queue[Int]()
    X(x - 1) = true
    Y(x - 1) = 0
    Q += x
    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
        }
      })
    }
  }
  BFS(1)

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