"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const n = parseInt(input[0].split(" ")[0]);
    const m = parseInt(input[0].split(" ")[1]);
    let abs = Array(n+1).fill(0).map(_ => [])
    for (let i = 1; i < input.length; i++) {
        let [a, b] = input[i].split(" ").map(el => parseInt(el))
        abs[a].push(b)
        abs[b].push(a)
    }
    let dp = {}
    dp[1] = 1
    let q = [1]
    let seen = new Set()
    while (q.length > 0) {
        let id = q.shift()
        for (let key of abs[id]) {
            if (!seen.has(key)) {
                dp[key] = id
                q.push(key)
                seen.add(key)
            }
        }
    }
    if (n !== Object.keys(dp).length) {
        console.log('No')
        return
    }
    console.log('Yes')
    for (let i = 2; i <= n; i++) {
        console.log(dp[i])
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));