import java.util.Scanner

import scala.annotation.tailrec

object Main extends App {
  val sc = new Scanner(System.in)
  val N, M = sc.nextInt
  val graph = (0 until M).foldLeft(Vector.fill(N)(Vector.empty[Int])) { (acc, _) =>
    val A, B = sc.nextInt - 1
    acc.updated(A, acc(A) :+ B).updated(B, acc(B) :+ A)
  }

  val ps = loop(Vector.fill(N)(-1).updated(0, 0), graph(0).map(_ -> 0)).tail
  println("Yes")
  ps.foreach(p => println(p + 1))

  @tailrec def loop(acc: Vector[Int], nexts: Vector[(Int, Int)]): Vector[Int] = nexts match {
    case (room, prev) +: rest if acc(room) == -1 =>
      loop(acc.updated(room, prev), rest ++ graph(room).withFilter(r => acc(r) == -1).map(_ -> room))
    case _ +: rest =>
      loop(acc, rest)
    case _ => acc
  }

}

