import java.io.*
import java.util.*
import java.lang.Math.*


fun main() {
    val (N,M) = rd.readIntArray()
    val egs = edge<Int>(N)
    for (i in 0 until M) {
        var (A, B) = rd.readIntArray()
        A--;B--
        egs[A].add(B)
        egs[B].add(A)
    }

    val que = ArrayDeque<Int>()
    que.push(0)
    val dist = IntArray(N){INF}
    dist[0] = 0
    val pre = IntArray(N){-1}
    while (que.isNotEmpty()) {
        val x = que.removeFirst()

        for (nx in egs[x]) {
            if (dist[nx] > dist[x] + 1) {
                dist[nx] = dist[x] + 1
                pre[nx] = x
                que.addLast(nx)
            }
        }
    }

    println("Yes")
    for (i in 1 until N) {
        println(pre[i]+1)
    }
}


//val rd = debug.Reader("abc", "168", "d", "sample-1")
val rd = Reader()
fun main(args: Array<String>) {
    Thread(null, MainThread(), "mainThread", 128 * 1024 * 1024).start()
}


const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
class MainThread : Runnable {
    override fun run() { main() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}
