function main(input) {
  let [n, m] = input[0].trim().split(" ").map(i => parseInt(i));
  
  let [a,b] = [[], []];
  let map = {};
  for(let i=0;i<m;i++){
    [a[i],b[i]] = input[i+1].trim().split(" ").map(i => parseInt(i-1));
    if(map[a[i]]===undefined){
      map[a[i]] = [];
    }
    if(map[b[i]]===undefined){
      map[b[i]] = [];
    }
    map[a[i]].push({value: b[i], dep: -1});
    map[b[i]].push({value: a[i], dep: -1});
  }

  function getDeapth(deapth, before, now){
    for(let i=0;i<map[now].length;i++){
      if(map[now][i].dep===-1){
        map[now][i].dep = deapth +1;
        map[now][i].before = before;
        getDeapth(deapth+1, now, map[now][i].value);
      }
    }
  }

  getDeapth(0,0,0);

  console.log(map);

  if(map[0]!==undefined){
    console.log("Yes");
    for(let i=0;i<Object.keys(map).length;i++){
      if(i!==0){
        let min = Infinity;
        let bef;
        for(let j of map[i]){
          if(j.dep<min){
            bef = j.before;
          }
        }
        console.log(bef+1);
      }
    }
  }else{
    console.log("No");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));