"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.trim().split(/ |\n/), cid = 0;

function main() {
    let N = +cin.shift();
    let M = +cin.shift();
    let A;
    let B;
    let possible = Array(N + 1);
    for (let i = 0; i < N + 1; i++)possible[i] = [];
    for (let i = 0; i < M; i++) {
        A = +cin.shift();
        B = +cin.shift();
        possible[A].push(B);
        possible[B].push(A);
    }
    //    console.log({ possible });
    let kyori = Array(N + 1).fill(N);
    kyori[1] = 0;
    for (let i = 1; i <= N; i++) {
        possible[i].forEach(v => { kyori[v] = Math.min(kyori[i] + 1, kyori[v]); });
    }
    //console.log({ kyori });

    let ans = Array(N + 1);
    ans[0] = "Yes";

    for (let i = 2; i <= N; i++) {
        let tonari = possible[i];
        for (let j = 0; j < tonari.length; j++) {
            let v = tonari[j];
            if (kyori[v] == kyori[i] - 1) {
                ans[i] = v;
                break;
            }
        }
    }
    ans.splice(1, 1); // indexがずれているので調整。
    console.log(ans.join("\n"));

}

main();