import java.util.Scanner

import scala.collection.immutable.{Map, Queue}
import scala.collection.mutable.ArrayBuffer

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: Queue[Int] = Queue(0), preMap: Map[Int, Int] = Map(0 -> 0)): Map[Int, Int] =
	{
		if (queue.isEmpty) preMap
		else {
			val (node, remain) = queue.dequeue
			val (nextQueue, nextMap) = adj(node).foldLeft[(Queue[Int], Map[Int, Int])](remain, preMap) { case ((tmpQueue, tmpMap), nextNode) =>
				preMap get nextNode match {
					case Some(_) => (tmpQueue, tmpMap)
					case None => (tmpQueue.enqueue(nextNode), tmpMap.updated(nextNode, node))
				}
			}
			calc(nextQueue, nextMap)
		}
	}
	
	private def readInts(): (Int, Int) =
	{
		(sc.nextInt(), sc.nextInt())
	}
}