import java.util.Scanner

import scala.collection.mutable

object Main extends App {
  val sc = new Scanner(System.in)
  val (n, m) = (sc.nextInt(), sc.nextInt())
  val routes = (1 to m).map { _ => (sc.nextInt(), sc.nextInt()) }

  val table = buildTable(routes)
  val result = mutable.Map[Int, Int]()
  val nextRooms = mutable.ListBuffer(1)
  var count = 0
  while(result.size < n) {
    val before = nextRooms.clone()
    nextRooms.clear()
    before.foreach { room =>
      table(room).foreach { nextRoom =>
        if(!result.isDefinedAt(nextRoom)) {
          result(nextRoom) = room
          nextRooms += nextRoom
        }
      }
    }
    count += 1
  }

  println("Yes")
  (2 to n).foreach { room => println(result(room)) }

  def buildTable(routes: Seq[(Int, Int)]): Map[Int, List[Int]] = {
    val builder = mutable.Map[Int, List[Int]]().withDefaultValue(Nil)
    routes.foreach { case(x, y) =>
      builder(x) +:= y
      builder(y) +:= x
    }
    builder.toMap
  }
}
