import java.util.Scanner

import scala.annotation.tailrec
import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val n, m = sc.nextInt()
    val arr = Array.fill(n)(Vector.empty[Int])

    for (_ <- 0 until m) {
      val a, b = sc.nextInt()
      arr(a - 1) = arr(a - 1) :+ (b - 1)
      arr(b - 1) = arr(b - 1) :+ (a - 1)
    }

    println("Yes")

    val visited = Array.fill(n)(false)
    val ans = Array.fill(n)(-1)
    val queue = mutable.Queue(0)

    while (queue.nonEmpty) {
      val q = queue.dequeue()
      visited(q) = true
      arr(q)
        .filter(m => !visited(m))
        .foreach(i => {
          if (ans(i) == -1) {
            ans(i) = q
            queue.enqueue(i)
          }
        })
    }

    ans.tail.foreach(j => println(j + 1))
  }

  //region

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
    Console.err.flush()
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

  def bitSearch[T](n: Int, choice: Vector[T]): Vector[Vector[T]] = {
    @tailrec
    def bitSearchLogic(n: Int,
                       choice: Vector[T],
                       acc: Vector[Vector[T]]): Vector[Vector[T]] = {
      if (n == 0) acc
      else {
        val newAcc =
          acc.flatMap(vec => {
            choice.map(c => vec :+ c)
          })
        bitSearchLogic(n - 1, choice, newAcc)
      }
    }

    val firstAcc = choice.map(i => Vector(i))
    bitSearchLogic(n - 1, choice, firstAcc)
  }
  //endregion
}
