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

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)
	}
	
	val resultPreMap = calc()
	println("Yes")
	(2 to n).foreach(node => println(resultPreMap(node)))
	
	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) =
	{
		val arr = readLine().split(" ", 2).map(_.toInt)
		(arr(0), arr(1))
	}
}