import java.util.Scanner

fun main() {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val m = scn.nextInt()
	val ps = Array(n){ mutableListOf<Int>()}
	repeat(m) {
		val a = scn.nextInt()-1
		val b = scn.nextInt()-1
		ps[a].add(b)
		ps[b].add(a)
	}
	val d = IntArray(n){Integer.MAX_VALUE}
	d[0] = 0
	val arr = IntArray(n)
	val q = mutableListOf(0)
	while(q.size>0){
		val i = q.removeAt(0)
		ps[i].forEach{
			if (d[i]+1<d[it]){
				d[it] = d[i]+1
				arr[it] = i
				q.add(it)
			}
		}
	}
	if (d.any{it==Integer.MAX_VALUE}){
		println("No")
	}else {
		println("Yes")
		for (i in 1 until n) println(arr[i]+1)
	}
}