function main(input) {
  let [n,m] = input[0].trim().split(" ").map(i => parseInt(i));

  let [a,b] = [[],[]];
  let adjacentList = [];
  for(let i=1;i<m+1;i++){
    [a[i],b[i]] = input[i].trim().split(" ").map(i => parseInt(i-1));
    if(adjacentList[a[i]]===undefined){
      adjacentList[a[i]]=[];
    }
    adjacentList[a[i]].push(b[i]);
    if(adjacentList[b[i]]===undefined){
      adjacentList[b[i]]=[];
    }
    adjacentList[b[i]].push(a[i]);
  }

  let visited = new Array(n).fill(-1);

  let queue = [0];

  while(queue.length != 0) {
    let currentNode = queue.pop()

    for(let nextNode of adjacentList[currentNode]) {
      if(visited[nextNode] != -1) continue
      visited[nextNode] = currentNode+1;
      queue.unshift(nextNode);
    }
  }
  console.log("Yes")
  visited.shift()
  console.log(visited.map((i)=>(i+"\n")).join(""))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));