module graph
      type node
        integer :: num = 0
        integer :: tmp = 0
        integer :: ans
        integer :: loc = 1000
        integer, allocatable :: edge(:)
      end type node

end module graph

program main
        use graph

        implicit none
        integer :: n, m, i, j, k, tmp, minl,cnt
        integer, allocatable :: a(:), b(:)
        type(node), allocatable :: nod(:)

        read *, n, m
        allocate( a(m), b(m) )
        allocate( nod(n) ) 

        do i = 1, m
          read *, a(i), b(i)
          nod(a(i))%num = nod(a(i))%num + 1
          nod(b(i))%num = nod(b(i))%num + 1
        end do
        do i = 1, n
          allocate( nod(i)%edge(nod(i)%num) )
        end do
        do i = 1, m
          nod(a(i))%tmp = nod(a(i))%tmp + 1
          cnt = nod(a(i))%tmp
          nod(a(i))%edge(cnt) = b(i)

          nod(b(i))%tmp = nod(b(i))%tmp + 1
          cnt = nod(b(i))%tmp
          nod(b(i))%edge(cnt) = a(i)
        end do

        nod(1)%loc = 0
        do j = 1, nod(1)%num
          k = nod(1)%edge(j)
          nod(k)%loc = 1
          nod(k)%ans = 1
        end do

        do i = 2, n 
          minl = 1000
          do j = 1, nod(i)%num
            k = nod(i)%edge(j) 
            if ( minl > nod(k)%loc ) then
              minl = nod(k)%loc
              tmp  = k
            end if
          end do
          nod(i)%loc = minl+1
          nod(i)%ans = tmp
        end do

        print *, 'Yes'
        do i = 2, n
          print *, nod(i)%ans
        end do

end program main
