import scala.collection.immutable.{IntMap, TreeMap}
import scala.io.StdIn._

object Main extends App
{
	type PathMap = IntMap[Set[Int]]
	type Edge = (Int, Int)
	val (n, m) = readInts()
	
	val (pathMap, edgeList): (PathMap, List[Edge]) = (1 to m).foldLeft[(PathMap, List[Edge])]((IntMap.empty, List.empty)) { case ((map: PathMap, list: List[Edge]), _) =>
		val (from, to) = readInts()
		val fromSet = map.getOrElse(from, Set.empty)
		val toSet = map.getOrElse(to, Set.empty)
		(map.updated(from, fromSet + to).updated(to, toSet + from), (from, to) :: list)
	}
	
	val depthMap = calc()
	if (depthMap.size != n) {
		println("No")
	}
	else {
		println("Yes")
		val resultMap = edgeList.foldLeft[Map[Int, Int]](Map.empty) { case (tmap, (from: Int, to: Int)) =>
			tmap.updatedWith(from)(chooseShallower(to, _)).updatedWith(to)(chooseShallower(from, _))
		}
		(2 to n).foreach(node => println(resultMap(node)))
	}
	
	private def chooseShallower(newNode: Int, oldNode: Option[Int]): Option[Int] =
	{
		oldNode match {
			case None => Some(newNode)
			case Some(old) => if (depthMap(newNode) < depthMap(old)) Some(newNode) else oldNode
		}
	}
	
	private def calc(fromSet: Set[Int] = Set(1), depth: Int = 1, distMap: Map[Int, Int] = Map(1 -> 0)): Map[Int, Int] =
	{
		val toRooms: Set[Int] = fromSet.flatMap(pathMap(_)).filterNot(distMap.contains)
		if (toRooms.isEmpty) distMap
		else {
			val newMap = toRooms.foldLeft(distMap) { case (map, toRoom) => map.updated(toRoom, depth) }
			calc(toRooms, depth + 1, newMap)
		}
		
	}
	
	
	private def readInts(): (Int, Int) =
	{
		val arr = readLine().split(" ", 2).map(_.toInt)
		(arr(0), arr(1))
	}
}