(args => {
  const [[N,M],...path] = args.trim().split('\n').map(a=>a.split(' ').map(a=>a|0));
  const map = {}, room = [0];
  for ( let i = 1; i <= N; i++ ) {
    map[i] = { dist: N+1, branch: [] };
    room[i] = N+1;
  }
  for ( let i = 0; i < M; i++ ) {
    const [A,B] = path[i];
    map[A].branch.push(B);
    map[B].branch.push(A);
  }
  let mark = (step,i) => {
    const {branch} = map[i];
    for ( let j = branch.length; j > 0; j-- ) {
      const dest = branch[j-1];
      if ( map[dest].dist > step ) {
        map[dest].dist = step;
        room[dest] = i;
        mark(step+1,dest);
      }
    }
  }
  mark(0,1);
  if ( room.slice(2).some(v=>v===N+1) ) return console.log('No');
  console.log('Yes\n'+room.slice(2).join('\n'));
})(require('fs').readFileSync('/dev/stdin', 'utf8'))