import java.util.Scanner

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val 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()
      g(v).foreach { i =>
        if (!(x(i - 1))) {
          x(i - 1) = true
          y(i - 1) = v
          q.enqueue(i)
        }
      }
    }

    println("Yes")
    println(y.tail.mkString("\n"))

  }
}
