function Main(input){
  input = input.trim().split('\n');
  const nm = input.shift().split(' ').map(x=>parseInt(x));
  const n = nm[0];
  const m = nm[1];
  input = input.map(x=>x.split(' ').map(y=>parseInt(y)));
  var routes = input;
  var rooms = [];
  for (let i=1;i<=n;i++){
    if (i==1){
      rooms.push([i,0,0]);
    }else{
      rooms.push([i,0,100000]);
    }
  }
  var oriTargs = [1];
  var newTargs = [];
  var doneNum = 0;
  while (doneNum < 3){
    for (let i=0;i<oriTargs.length;i++){
      var j = 0;
      while (j < routes.length){
        if (routes[j].indexOf(oriTargs[i]) !== -1){
          var tmp = routes[j].indexOf(oriTargs[i]);
          tmp = routes[j][1 - tmp];
          if (rooms[tmp - 1][2] > rooms[oriTargs[i] - 1][2] + 1){
            rooms[tmp - 1][1] = oriTargs[i];
            rooms[tmp - 1][2] = rooms[oriTargs[i] - 1][2] + 1;
            if (newTargs.indexOf(tmp) == -1){
              newTargs.push(tmp);
            }
          }
          routes.splice(j,1);
        }else{
          j++;
        }
      }
      doneNum++;
    }
    oriTargs = newTargs;
    newTargs = [];
  }
  var ans = ['Yes'];
  for (let i=1;i<rooms.length;i++){
    ans.push(rooms[i][1]);
  }
  var ansStr = ''
  for (let i=0;i<ans.length;i++){
    ansStr += ans[i]+'\n';
  }
  ansStr.trim();
  console.log(ansStr);
}


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