s=list(input())
if s[0]=='0':
  t=int(s[1])
  
else:
  t=int(''.join(s[:2]))
if s[2]=='0':
  u=int(s[3])
else:
  u=int(''.join(s[2:]))

if t>=1 and t<=12:
  if u>=1 and u<=12:
    print('AMBIGUOUS')
    
  else:
    print('MMYY')
    
else:
  if u>=1 and u<=12:
    print('YYMM')
    
  else:
    print('NA') s=list(input()) s list(input()) list input() input if s[0]=='0':
  t=int(s[1])
  
else:
  t=int(''.join(s[:2])) s[0]=='0' s[0] s 0 '0' t=int(s[1]) t int(s[1]) int s[1] s 1 t=int(''.join(s[:2])) t int(''.join(s[:2])) int ''.join(s[:2]) ''.join '' join s[:2] s :2 2 if s[2]=='0':
  u=int(s[3])
else:
  u=int(''.join(s[2:])) s[2]=='0' s[2] s 2 '0' u=int(s[3]) u int(s[3]) int s[3] s 3 u=int(''.join(s[2:])) u int(''.join(s[2:])) int ''.join(s[2:]) ''.join '' join s[2:] s 2: 2 if t>=1 and t<=12:
  if u>=1 and u<=12:
    print('AMBIGUOUS')
    
  else:
    print('MMYY')
    
else:
  if u>=1 and u<=12:
    print('YYMM')
    
  else:
    print('NA') t>=1 and t<=12 t>=1 t 1 t<=12 t 12 if u>=1 and u<=12:
    print('AMBIGUOUS')
    
  else:
    print('MMYY')
     u>=1 and u<=12 u>=1 u 1 u<=12 u 12 print('AMBIGUOUS') print 'AMBIGUOUS' print('MMYY') print 'MMYY' if u>=1 and u<=12:
    print('YYMM')
    
  else:
    print('NA') u>=1 and u<=12 u>=1 u 1 u<=12 u 12 print('YYMM') print 'YYMM' print('NA') print 'NA' s=list(input()) list(input()) s t=int(s[1]) int(s[1]) t t=int(''.join(s[:2])) int(''.join(s[:2])) t u=int(s[3]) int(s[3]) u u=int(''.join(s[2:])) int(''.join(s[2:])) u
s=list(input())
if s[0]=='0':
  t=int(s[1])
  
else:
  t=int(''.join(s[:2]))
if s[2]=='0':
  u=int(s[3])
else:
  u=int(''.join(s[2:]))

if t>=1 and t<=12:
  if u>=1 and u<=12:
    print('AMBIGUOUS')
    
  else:
    print('MMYY')
    
else:
  if u>=1 and u<=12:
    print('YYMM')
    
  else:
    print('NA')