implicit none
integer :: a
integer :: XX, YY
read *,a

XX = a / 100
YY = mod(a,100)

if (0 < YY .and. YY < 13) then  ! YY can be year or month
   if (0 < XX .and. XX < 13) then  ! XX can be year or month
      write(6,'(a)') 'AMBIGUOUS'
   else  ! XX is year
      write(6,'(a)') 'YYMM'
   endif
else  ! YY is year
   if (0 < XX .and. XX < 13) then  ! XX can be year or month
      write(6,'(a)') 'MMYY'
   else  ! XX iss year
      write(6,'(a)') 'NA'
   endif
endif

stop
end