"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 = {}
    for(let i = 1; i<input.length; i++){
        let [a,b] = input[i].split(" ").map(el => parseInt(el))
        if(!abs[a]) abs[a] = {}
        abs[a][b] = 1
        if(!abs[b]) abs[b] = {}
        abs[b][a] = 1
    }
    let dp = {}
    dp[1] = 1
    let q = [1]
    while(q.length>0){
        let id = q.shift()
        for(let key of Object.keys(abs[id])){
            if(!dp[key]){
                dp[key] = id
                q.push(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'));  
