import scala.collection.immutable.TreeMap
import scala.collection.mutable.{Queue => MQueue, TreeMap => MTreeMap}
import scala.io.StdIn.readLine

object Main extends App
{
	val pattern = """(\d)* (\d)*""".r
	type PathMap = TreeMap[Int, List[Int]]
	val (n, m) = readInts()
	
	val pathMap: PathMap = (1 to m).foldLeft[PathMap](TreeMap.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: MQueue[Int] = MQueue(1), preMap: MTreeMap[Int, Int] = MTreeMap(1 -> 0)): MTreeMap[Int, Int] =
	{
		while (queue.nonEmpty) {
			val node = queue.dequeue()
			pathMap(node).foreach { nextNode =>
				val pre = preMap.get(nextNode)
				if (pre.isEmpty) {
					queue += nextNode
					preMap += Tuple2(nextNode, node)
				}
			}
		}
		preMap
	}
	
	private def readInts(): (Int, Int) =
	{
		readLine() match {
			case pattern(x, y) => (x.toInt, y.toInt)
		}
	}
}