import scala.collection.immutable.IntMap
import scala.io.StdIn._

object Main extends App
{
	type PathMap = IntMap[Set[Int]]
	type Edge = (Int, Int)
	val (n, m) = readInts()
	
	val pathMap: PathMap = (1 to m).foldLeft[PathMap](IntMap.empty) { case (map: PathMap, _) =>
		val (from, to) = readInts()
		val fromSet = map.getOrElse(from, Set.empty)
		val toSet = map.getOrElse(to, Set.empty)
		map.updated(from, fromSet + to).updated(to, toSet + from)
	}
	
	val resultMap = calc()
	if(resultMap.size != n){
		println("No")
	}
	else{
		println("Yes")
		(2 to n).foreach(node => println(resultMap(node)))
	}
	
	
	
	private def calc(fromSet: Set[Int] = Set(1), nodeToBeforeNode: Map[Int, Int] = Map(1 -> 0)): Map[Int, Int] =
	{
		val visited = nodeToBeforeNode.keySet
		val (next, nextNodes) = fromSet.foldLeft[(Map[Int, Int], Set[Int])]((nodeToBeforeNode, Set.empty)) { case ((tmp, set:Set[Int]), from: Int) =>
			val toRoom = pathMap(from).filterNot(visited.contains)
			val nextMap = toRoom.foldLeft[Map[Int, Int]](tmp) { case (map, to: Int) => map.updated(to, from) }
			(nextMap, set ++ toRoom)
		}
		if(nextNodes.isEmpty) nodeToBeforeNode
		else{
			calc(nextNodes, next)
		}
		
	}
	
	
	private def readInts(): (Int, Int) =
	{
		val arr = readLine().split(" ", 2).map(_.toInt)
		(arr(0), arr(1))
	}
}