// parameter "input" gets all data
function Main(input) {
   // the first line is assigned to input[0], the second line is assigned to input[1] similarly.
    input = input.split("\n");
var f=[]
    let tmp = input[0].split(' ')
    const [n,m]=tmp
    let p=[]
    for (let i=1;i<=Number(m);i++){
        let [l,r]=input[i].split(' ')
        l=Number(l)
        r=Number(r)
      if (p[l]){
        p[l].push(r)
      } else {
        p[l]=[r]
      }
      if (p[r]){
        p[r].push(l)
      } else {
        p[r]=[l]
      }
    }
    f[1]=1
    let tot=0
    let ans=[1]
    let check=(index)=>{
        f[index] && tot++
        for (let j of p[index]){
            !f[j] && (f[j] = index) && ans.push(j)
        }
    }
while (ans.length>0){
    check(ans[0])
    ans.shift()
}

  console.log(tot === Number(n)?'Yes':'No')
  if (tot === Number(n)){
    for (let i=2;i<=Number(n);i++){
        console.log(f[i])
    }  
  }

}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
