inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
N = l.shift() * 1
M = l.shift() * 1 
a = []
for(i=0;i<=N;i++) {
    a[i] = []
}
t = new Array(N+1)
s = new Array(N+1)
for (i=0; i<M; i++) {
    l = inp.shift().split(" ").map(x => +x)
    a[l[1]].push(l[0])
    a[l[0]].push(l[1])
}
p = [[1, 1, a[1]]]
t[1] = 0
s[1] = 0
cnt = 1;

while(p.length) {
    d = p.pop()
    while(d[2].length) {
        e = d[2].pop()
        if (t[e] === undefined || s[e] > d[0]) {
            if (t[e] === undefined) {
                cnt++
                p.push([d[0] + 1, e, a[e]])
            }
            t[e] = d[1]
            s[e] = d[0]
        }
    }
}
if (cnt === N) {
    console.log("Yes")
    for(i=2; i<N+1; i++) {
        console.log(t[i])
    }
} else {
    console.log("No")
}
