import java.util.Scanner

import scala.collection.mutable.{ArrayBuffer, Map => MMap, Queue => MQueue}

object Main extends App
{
	val sc = new Scanner(System.in)
	val (n, m) = readInts()
	
	val adj = ArrayBuffer.fill(n)(List.empty[Int])
	(1 to m).foreach { _ =>
		val (from, to) = readInts()
		adj(from - 1) ::= to - 1
		adj(to - 1) ::= from - 1
	}
	
	val resultPreMap = calc()
	println("Yes")
	(1 until n).foreach(node => println(resultPreMap(node) + 1))
	
	private def calc(queue: MQueue[Int] = MQueue(0), preMap: MMap[Int, Int] = MMap(0 -> 0)): MMap[Int, Int] =
	{
		while (queue.nonEmpty) {
			val node = queue.dequeue()
			for (nextNode <- adj(node) if !preMap.contains(nextNode)) {
				queue += nextNode
				preMap += Tuple2(nextNode, node)
			}
		}
		preMap
	}
	
	private def readInts(): (Int, Int) =
	{
		(sc.nextInt(), sc.nextInt())
	}
}