program main
 implicit none
 
 character*80 s
 integer*8 B,A,db,da
 db = 0
 da = 0
 read(*,*) s
 read(s(1:2),*) B
 read(s(3:4),*) A
 
 if(B == 0 .or. B > 12) then
  db = 1
 end if
 if(A == 0 .or. A > 12) then
  da = 1
 end if
 
 if(db == 0 .and. da == 0) then
  write(*,*) 'AMBIGUOUS'
 else if(db == 0 .and. da == 1) then
  write(*,*) 'MMYY'
 else if(db == 1 .and. da == 0) then
  write(*,*) 'YYMM'
 else
  write(*,*) 'NA'
 end if
end program main