function main(input) {
  const args = input.split("\n");
  const [N, M] = args[0].split(" ").map((n) => parseInt(n, 10));
  let AB = [];
  for (let i = 1; i <= M; i++) {
    const [currA, currB] = args[i].split(" ").map((n) => parseInt(n, 10));
    AB.push([currA, currB]);
  }

  const linkFrom = new Array(N).fill(false);
  linkFrom[0] = true;

  const calc = (...roomNums) => {
    let linkTo = [];

    for (const roomNum of roomNums) {
      if (linkFrom.includes(false)) {
        for (let i = 0; i < AB.length; i++) {
          const way = AB[i];

          if (way[0] === roomNum) {
            if (!linkFrom[way[1] - 1]) {
              linkFrom[way[1] - 1] = roomNum;
              linkTo.push(way[1]);
            }

            AB.splice(i, 1);
            i--;
          }
          else if (way[1] === roomNum) {
            if (!linkFrom[way[0] - 1]) {
              linkFrom[way[0] - 1] = roomNum;
              linkTo.push(way[0]);
            }

            AB.splice(i, 1);
            i--;
          }
        }
      }
    }

    if (linkTo.length)
      calc(...linkTo);
  };

  calc(1);

  let ans = [];
  if (!linkFrom.includes(false)) {
    ans.push('Yes');
    for (let i = 1; i < N; i++) {
      ans.push(linkFrom[i]);
    }
  }
  else {
    ans.push('No');
  }

  console.log(ans.join('\n'));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
