'use strict';
function Main(inputs) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const input = inputs.split("\n");
  const [n, m] = input[0].split(' ').map(Number);
  const michi = {};
  input.slice(1).filter(Boolean).forEach((line) => {
    const [a, b] = line.split(' ').map(Number);
    if(michi[a] == null){
      michi[a] = [b];
    }else{
      michi[a].push(b);
    }
    if(michi[b] == null){
      michi[b] = [a];
    }else{
      michi[b].push(a);
    }
  });
  const q = [];
  const deguti = Array(n + 1).fill(null);
  q.push(1);
  while(q.length > 0){
    const kitaheya = q.shift();
    michi[kitaheya].forEach((nextHeya) => {
      if(deguti[nextHeya] == null){
        q.push(nextHeya);
        deguti[nextHeya] = kitaheya;
      }
    });
  }
  console.log('Yes\n' + deguti.slice(2).join('\n'));
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
