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 A = AB.groupBy(_._1).map(x => x._1 -> x._2.map(_._2))
  val B = AB.groupBy(_._2).map(x => x._1 -> x._2.map(_._1))
  val G = (1 to N).map(x => {
    val a = A.contains(x)
    val b = B.contains(x)
    x -> ((a, b) match {
      case (true, true) => A(x) ++ B(x)
      case (true, false) => A(x)
      case (false, true) => B(x)
      case _ => Array(-1)
    })
  }).filterNot(_._2 sameElements Array(-1)).toMap

  val X = Array.fill(N)(false)
  val L = Array.fill(N)(-1)
  val Y = Array.fill(N)(-1)

  def BFS(x: Int): Unit = {
    val Q = new mutable.Queue[Array[Int]]()
    X(x - 1) = true
    L(x - 1) = 0
    Y(x - 1) = 0
    Q += Array(x, 0)
    while (Q.nonEmpty) {
      val v = Q.dequeue
      X(v(0) - 1) = true
      G(v(0)).foreach(i => {
        if (!X(i - 1)) {
          X(i - 1) = true
          L(i - 1) = v(1) + 1
          Y(i - 1) = v(0)
          Q += Array(i, v(1) + 1)
        }
      })
    }
  }
  BFS(1)

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