"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 = Array(M);
    let B = Array(M);
    let possible = [];
    for (let i = 0; i <= N; i++) possible.push(new Set());
    for (let i = 0; i < M; i++) {
        A[i] = +cin.shift();
        B[i] = +cin.shift();
        possible[A[i]].add(B[i]);
        possible[B[i]].add(A[i]);
    }
    let ans = Array(N);
    ans[0] = "Yes";
    let remain = Array(N + 1).fill(true); //計算未完了の部屋
    remain[1] = false;
    let remainNum = N - 1;
    let front = new Set([1]);
    while (remainNum > 0) {
        //console.log({ remain, front })
        if (front.size == 0) {
            console.log("No");
            return;
        }

        //console.log({ front });
        let next = new Set();
        front.forEach(v => {
            possible[v].forEach(vv => {
                if (remain[vv]) {
                    ans[vv - 1] = v;
                    remain[vv] = false;
                    remainNum--;
                    next.add(vv);
                }
            });
        });
        //console.log({ next, ans });
        front = next;
    }
    console.log(ans.join("\n"));
}
main();