import scala.collection.mutable.{Map => MMap, Queue => MQueue}
import scala.io.StdIn._

object Main extends App
{
	val pattern = """(\d)* (\d)*""".r
	type PathMap = MMap[Int, List[Int]]
	val (n, m) = readInts()
	
	val pathMap: PathMap = buildPathMap()
	
	val resultPreMap = calc()
	println("Yes")
	(2 to n).foreach(node => println(resultPreMap(node)))
	
	private def buildPathMap(): PathMap =
	{
		val pathMap = MMap.empty[Int,List[Int]].withDefaultValue(List.empty)
		(1 to m).foreach { _ =>
			val (from, to) = readInts()
			val fromList = pathMap(from)
			val toList = pathMap(to)
			pathMap.update(from, to :: fromList)
			pathMap.update(to, from :: toList)
		}
		pathMap
	}
	
	private def calc(queue: MQueue[Int] = MQueue(1), distMap: MMap[Int, Int] = MMap(1 -> 0), preMap: MMap[Int, Int] = MMap(1 -> 0)): MMap[Int, Int] =
	{
		while (queue.nonEmpty) {
			val node = queue.dequeue()
			pathMap(node).foreach { nextNode =>
				val dist = distMap.get(nextNode)
				if (dist.isEmpty) {
					queue += nextNode
					distMap += Tuple2(nextNode, distMap(node) + 1)
					preMap += Tuple2(nextNode, node)
				}
			}
		}
		preMap
	}
	
	private def readInts(): (Int, Int) =
	{
		readLine() match {
			case pattern(x, y) => (x.toInt, y.toInt)
		}
	}
}