      module piyoMod
      
      type rooms
        integer(16),allocatable :: nei(:)
        integer(16) :: numNei=0
      end type
      
      integer(16),allocatable :: flag(:)
      
      contains
      recursive subroutine solve( rIn,roomNum,before )
        implicit none
        type(rooms),intent(in),allocatable :: rIn(:)
        integer(16),intent(in) :: roomNum,before
        integer(16) :: i
        
        if( flag(roomNum)/=-1 ) return
        flag( roomNum ) = before
        if( rIn(roomNum)%numNei==0 ) return
        
        
        do i = 1,rIn(roomNum)%numNei
          call solve( rIn,rIn(roomNum)%nei(i),roomNum )
        end do
      end subroutine
      
      end module
      
      PROGRAM doubleDots
      use piyoMOd
      IMPLICIT NONE
      integer(16) :: n,m,buffer(10**5),numNei
      integer(16),allocatable :: a(:),b(:)
      type(rooms),allocatable :: room(:)
      integer(16) :: i
      
      read*,n,m
      allocate( a(m),b(m),room(n),flag(n) )
      flag(1:n) = -1
      do i = 1,m
        read*,a(i),b(i)
      end do
      
      do i = 1,m
        room(a(i))%numNei = room(a(i))%numNei + 1
        numNei = room(a(i))%numNei
        buffer(1:numNei-1) = room(a(i))%nei
        if(allocated(room(a(i))%nei) )deallocate( room(a(i))%nei )
        buffer(numNei) = b(i)
        room(a(i))%nei = buffer(1:numNei)
        
        room(b(i))%numNei = room(b(i))%numNei + 1
        numNei = room(b(i))%numNei
        buffer(1:numNei-1) = room(b(i))%nei
        if(allocated(room(b(i))%nei) )deallocate( room(b(i))%nei )
        buffer(numNei) = a(i)
        room(b(i))%nei = buffer(1:numNei)
      end do
      
      
      call solve( room,1_16,0_16 )
      
      if( count(flag(2:n)==-1) >=1 )then
        print*,'No';stop
      end if
      
      print*,'Yes'
      do i = 2,n
        print*,flag(i)
      end do
      
      
      
      
      
      
   !   print*,n,m
   !   do i = 1,m
   !     print*,a(i),b(i)
   !   end do
      
      
   !   do i= 1,n
   !     print*,'room',i,room(i)%numNei
   !     print*,room(i)%nei
   !   end do
      
      END PROGRAM