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

object Main extends App
{
	type PathMap = IntMap[List[Int]]
	val (n, m) = readInts()
	
	val pathMap: PathMap = (1 to m).foldLeft[PathMap](IntMap.empty) { case (map: PathMap, _) =>
		val (from, to) = readInts()
		val fromList = map.getOrElse(from, List.empty)
		val toList = map.getOrElse(to, List.empty)
		map.updated(from, to :: fromList).updated(to, from :: toList)
	}
	
	val resultPreMap = calc()
	println("Yes")
	(2 to n).foreach(node => println(resultPreMap(node)))
	
	private def calc(queue: Queue[Int] = Queue(1), distMap: Map[Int, Int] = Map(1 -> 0), preMap: Map[Int, Int] = Map(1 -> 0)): Map[Int, Int] =
	{
		if (queue.isEmpty) preMap
		else {
			val (node, remain) = queue.dequeue
			val (nextQueue, nextDistMap, nextPreMap) =
				pathMap(node).foldLeft[(Queue[Int], Map[Int, Int], Map[Int, Int])](remain, distMap, preMap) { case ((tmpQueue, dMap, pMap), nextNode) =>
					val dist = dMap.get(nextNode)
					if (dist.nonEmpty) {
						(tmpQueue, dMap, pMap)
					}
					else {
						(
							tmpQueue.enqueue(nextNode),
							dMap.updated(nextNode, distMap(node) + 1),
							pMap.updated(nextNode, node)
						)
					}
				}
			calc(nextQueue, nextDistMap, nextPreMap)
		}
	}
	
	
	private def readInts(): (Int, Int) =
	{
		val arr = readLine().split(" ", 2).map(_.toInt)
		(arr(0), arr(1))
	}
}