fun read(d:String = " ") = readLine()!!.split(d)
fun <T> readList(d:String = " ",f:String.()->T) = read(d).map {f(it)}

fun main() {
	val (n,m) = readList {toInt()}
	val neighbor = Array(n) {mutableSetOf<Int>()}

	for(i in 1..m) {
		val (a,b) = readList {toInt()-1}
		neighbor[a].add(b)
		neighbor[b].add(a)
	}

	val parent = IntArray(n) {-1}

	val o = mutableSetOf(0)
	while(o.isNotEmpty()) {
		val p = o.toSet()
		o.clear()
		for(i in p) {
			neighbor[i].asSequence().filter {parent[it]<0}.forEach {
				parent[it] = i+1
				o.add(it)
			}
		}
	}

	println("Yes")
	parent.drop(1).forEach(::println)
}
