import scala.collection.immutable.{Map, Queue}
import scala.io.StdIn.readLine

object Main extends App
{
	type PathMap = Map[Int, List[Int]]
	val (n, m) = readInts()
	
	val pathMap: PathMap = (1 to m).foldLeft[PathMap](Map.empty.withDefaultValue(List.empty)) { case (map: PathMap, _) =>
		val (from, to) = readInts()
		val fromList = map(from)
		val toList = map(to)
		map.updated(from, to :: fromList).updated(to, from :: toList)
	}
	
	lazy val resultPreMap = calc()
	println("Yes")
	(2 to n).foreach(node => println(resultPreMap(node)))
	
	private def calc(queue: Queue[Int] = Queue(1), preMap: Map[Int, Int] = Map(1 -> 0)): Map[Int, Int] =
	{
		if (queue.isEmpty) preMap
		else {
			val (node, remain) = queue.dequeue
			lazy val neverVisited = pathMap(node).filterNot(preMap.contains)
			lazy val (nextQue, nextPreMap) = neverVisited.foldLeft[(Queue[Int], Map[Int, Int])](remain, preMap) { case ((tmpQueue, tmpMap), nextNode) =>
				preMap get nextNode match {
					case None => (tmpQueue.enqueue(nextNode), tmpMap.updated(nextNode, node))
				}
			}
			calc(nextQue, nextPreMap)
		}
	}
	
	private def readInts(): (Int, Int) =
	{
		val line = readLine().split(" ", 2).map(_.toInt)
		(line(0), line(1))
	}
}