import java.util.Scanner

import scala.annotation.tailrec
import scala.collection.immutable.Queue

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

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

  @tailrec def loop(acc: Array[Int], nexts: Queue[(Int, Int)]): Array[Int] = nexts.dequeueOption match {
    case Some(((room, prev), rest)) if acc(room) == -1 =>
      loop(acc.updated(room, prev), rest.enqueue(graph(room).map(_ -> room)))
    case Some((_, rest)) =>
      loop(acc, rest)
    case _ => acc
  }

}
