import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(n, m) = in.readLine().split("\\s+").map(_.toInt)
    val paths = Array.fill(m) {
      in.readLine().split("\\s+").map(_.toInt) match {
        case Array(a, b) => (a - 1, b - 1)
      }
    }

    val room2room = Array.fill(n) {
      ArrayBuffer.empty[Int]
    }
    for (path <- paths) {
      room2room(path._1) += path._2
      room2room(path._2) += path._1
    }

    val signs = Array.fill(n)(Int.MinValue)

    System.err.println("=---")

    val restRooms = mutable.Queue.empty[(Int,Int)]
    restRooms.enqueue((-1, 0))

    while (restRooms.nonEmpty) {
      val (parentRoom, currentRoom) = restRooms.dequeue()
      if (signs(currentRoom) == Int.MinValue) {
        System.err.println(s"${currentRoom} sign = ${parentRoom}")
        signs(currentRoom) = parentRoom
        for (nextRoom <- room2room(currentRoom)) {
          restRooms.enqueue((currentRoom, nextRoom))
        }
      }
    }

    if (!signs.contains(Int.MinValue)) {
      out.println("Yes")
      for (i <- 1 until signs.length) {
        out.println(signs(i) + 1)
      }
    } else {
      out.println("No")
    }

    out.flush()
  }
}
