function D168(_input) {
    var lines = _input.split("\n");
    var [n, m] = lines.shift().split(' ').map(v => v*1);
    var map = ['1'];
    var result = {}

    function s(keys) {
        const arr = [];
        for (let i = 0; i < lines.length; i++) {
            const route = lines[i].split(' ');
            for (let j = 0, len = keys.length; j < len; j++) {
                const id = route.indexOf(keys[j]);

                if (id === 0) {
                    if (!result.hasOwnProperty(route[1])) result[route[1]] = keys[j];
                    arr.push(route[1]);
                } else if (id === 1) {
                    if (!result.hasOwnProperty(route[0])) result[route[0]] = keys[j];
                    arr.push(route[0]);
                }
            }
        }
        map = arr;
    }

    // 1と直接つながっている部屋を探す
    while(Object.keys(result).length < n) {
        s(map);
    }

    console.log('Yes');
    for (let i = 2; i < n + 1; i ++) {
        console.log(result[String(i)]);
    }
}
D168(require("fs").readFileSync("/dev/stdin", "utf8"));