import java.util.Scanner

class Queue[A](nl:List[A]=Nil, rl:List[A]=Nil) {
  private val normal:List[A] = nl
  private val reverse:List[A] = rl
  def enque(x:A):Queue[A] = new Queue(normal, x::reverse)
  def deque():(Option[A], Queue[A])= {
    (normal, reverse) match {
      case (Nil, Nil) => (None, this)
      case (Nil, xs) => {
        val ls = xs.reverse
        (Some(ls.head), new Queue(ls.tail, Nil))
      }
      case (x::xs, ys) => (Some(x), new Queue(xs, ys))
    }
  }
  def clear(): Queue[A] = new Queue(Nil,Nil)
  def isEmpty(): Boolean = this.count==0
  def count(): Int = normal.length + reverse.length
}

object Main extends App {
  def readALine(c:Int, ac:List[Int]):List[Int] =
    if (c > 0) readALine(c-1, sc.nextInt::ac) else ac.reverse
  def readLines(r:Int, c:Int, ac:List[List[Int]]):List[List[Int]] =
    if (r > 0) readLines(r-1, c, readALine(c, Nil)::ac) else ac.reverse
  val sc = new Scanner(System.in)
  val N,M = sc.nextInt
  val ls = readLines(M, 2, Nil)

  def makePassage(ls:List[List[Int]], ps:Array[List[Int]]): Array[List[Int]] = {
    if (ls.isEmpty) ps else {
      val p = ls.head
      val i = p.head-1
      val j = p.tail.head-1 
      ps.update(i, j::ps(i))
      ps.update(j, i::ps(j))
      makePassage(ls.tail, ps)
    }
  }
  val passage = makePassage(ls, Array.fill(N)(Nil))

  type Room  = Option[(Int,Int)]
  type QItem = (Int,Int)

  def solve(que:Queue[QItem], rooms:Array[Room]): Array[Room] = {
    def iter(curId:Int, ps:List[Int], qu:Queue[QItem], rm:Array[Room]): (Queue[QItem], Array[Room]) =
      if (ps.isEmpty) (qu, rm) else {
        val p = ps.head
        val (_, step) = rm(curId).get
        rm(p) match {
          case None => iter(curId, ps.tail, qu.enque(curId, p), rm.updated(p, Some(curId, step+1)))
          case _ => iter(curId, ps.tail, qu, rm)
        }        
      }

    que.deque() match {
      case (None, _) => rooms
      case (Some((preId, curId)), nextQue) => {
        val (qu, rm) = iter(curId, passage(curId), nextQue, rooms)
        solve(qu, rm)
      } 
    }
  }

  val rslt = solve(new Queue[(Int, Int)](List((-1, 0))), Array.fill(N)(None).updated(0, Some((-1, 0))))

  // println(rslt.mkString(","))

  if (rslt.forall((r) => r != None)) {    
    println("Yes")
    for (r <- rslt) {
      val Some((to, id)) = r
      if (id > 0) println(to+1)
    }
  } else println("No")

}