      MODULE intQueueMod
      implicit none
! Module for QUEUE : First in, First out
! reference : プログラミングコンテスト攻略のための
!              アルゴリズムとデータ構造

      integer(16),parameter :: binSize = 10**6
      integer(16),parameter :: precision = 16
      
      type intQueue
        private
        integer(precision) :: bin( 1:binSize ) = 0
        integer(precision) :: head = 1,   tail = 1
        !head : Where the head value is.
        !tail : Where the blank next to tail is.
        contains
        procedure,public,pass :: initialize => intInit
        procedure,public,pass :: isEmpty    => intIsEmpty
        procedure,public,pass :: isFull     => intIsFull
        procedure,public,pass :: enQueue    => intEnQ
        procedure,public,pass :: deQueue    => intDeQ
      end type
      
      contains
!Reset queue. Not nessesary in first time.
      pure subroutine intInit( q )
        implicit none
        class(intQueue),intent(inout) :: q
        
        q%head = 1
        q%tail = 1
      end subroutine intInit
      
!Check status
      pure function intIsEmpty( q ) result( ans )
        implicit none
        class(intQueue),intent(in) :: q
        logical :: ans
        
        ans = q%head==q%tail
      end function intIsEmpty
      
      
      pure function intIsFull( q ) result( ans )
        implicit none
        class(intQueue),intent(in) :: q
        logical :: ans
        
        ans = q%head==mod( q%tail+1,binSize )
      end function intIsFull

!set x to tail
      subroutine intEnQ( q,x )
        implicit none
        class(intQueue)      ,intent(inout) :: q
        integer(precision),intent(in   ) :: x
        
        if( q%isFull() )then
          print*,'Queue is full,Error!';stop
        else
          q%bin(q%tail) = x
          if( q%tail==binSize )then
            q%tail = 1
          else
            q%tail = q%tail + 1
          end if
        end if
      end subroutine intEnQ
      
!get x from head
      impure function intDeQ( q ) result( x )
        implicit none
        class(intQueue),intent(inout) :: q
        integer(precision) :: x
        
        if( q%isEmpty() )then
          print*,'Stack is empty, Error!';stop
        else
          x = q%bin(q%head)
          if( q%head==binSize )then
            q%head = 1
          else
            q%head = q%head + 1
          end if
        end if
      end function intDeQ
      END MODULE intQueueMod
      
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      MODULE graphMod
      implicit none
! 重みなしのグラフを扱うためのモジュール

      integer(16),parameter,private :: prec = 16
      
      type :: nodes
        integer(prec),allocatable :: next(:)
        integer(prec) :: degree = 0
        contains
        procedure,public,pass :: appendNode
      end type
      
      contains
      subroutine appendNode( node, nodeNumber )
        implicit none
        class(nodes),intent(inout) :: node
        integer(prec),intent(in)  :: nodeNumber
        integer(prec),allocatable :: buffer(:)
        
        if(.not.(allocated(node%next)))then
          allocate(node%next(1))
          node%degree = 0
        end if
        
        if( node%degree==0 )then
          node%next(1) = nodeNumber
          node%degree = 1
          return
        end if
        
        node%degree = node%degree + 1
        buffer = node%next(1:node%degree-1)
        if( size(node%next)<node%degree )then
          deallocate( node%next )
          allocate( node%next(node%degree*2) )
        end if
        node%next(1:node%degree) = [buffer(1:node%degree-1), nodeNumber]
        deallocate( buffer )
      end subroutine appendNode
      
      END MODULE graphMod
      
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



      module piyoMod
      use intQueueMod
      use graphMod
      
      integer(16),allocatable :: flag(:)
      type(intQueue) :: nextQ,beforeQ
      
      contains
      subroutine solve( rIn,roomNum,before )
        implicit none
        type(nodes),intent(in) :: rIn(:)
        integer(16),intent(in) :: roomNum,before
        integer(16) :: i
        
        if( flag(roomNum)/=-1 ) return
        flag( roomNum ) = before
        if( rIn(roomNum)%degree==0 ) return
        
        do i = 1,rIn(roomNum)%degree
          call nextQ%enQueue( rIn(roomNum)%next(i) )
          call beforeQ%enQueue( roomNum )
        end do
        
      end subroutine
      end module
      
      PROGRAM doubleDots
      use piyoMod
      IMPLICIT NONE
      integer(16) :: n,m,numNei,buffer(5*10**5+1)
      integer(16),allocatable :: a(:),b(:)
      type(nodes),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
        call room(a(i))%appendNode( b(i) )
        call room(b(i))%appendNode( a(i) )
      end do
      
      
      
 !     call nextQ%enQueue(1_16)
 !     call beforeQ%enQueue(0_16) !dummy
 !     do while( .true. )
 !       if( nextQ%isEmpty() ) exit
 !       call solve( room,nextQ%deQueue(),beforeQ%deQueue() )
 !     end do
      
      
      
      
      if( count(flag(2:n)==-1) >=1 )then
        print*,'No';stop
      end if
      
      print*,'Yes'
      do i = 2,2
        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