const main = (input) => {
  const args = input.split('\n')
  const nm = args[0].split(' ').map(v => Number(v))
  const n = nm[0]
  const m = nm[1]
  let lines = args.slice(1, args.length).map(line => line.split(' ').map(v => Number(v)))
  let prev = Array(n).fill(-1)
  prev[0] = 0
  const queue = []
  queue.push(1)
  while(queue.length > 0) {
    const p = queue.shift()
    for(let i=0; i<m; i++) {
      if (lines[i][0] === p && prev[lines[i][1]-1] === -1) {
        queue.push(lines[i][1])
        prev[lines[i][1]-1] = p
      } else if (lines[i][1] === p && prev[lines[i][0]-1] === -1) {
        queue.push(lines[i][0])
        prev[lines[i][0]-1] = p
      }
    }
  }
  if(prev.includes(-1)) {
    console.log('No')
  } else {
    prev.forEach((v, i) => {
      if(i === 0) {
        console.log('Yes')
      } else {
        console.log(v)
      }
    })
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))