s=input()
a=int(s[0:2])
b=int(s[2:4])
if 0<a<13:
  if 0<b<13:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0<b<13:
    print('YYMM')
  else:
    print('NA') s=input() s input() input a=int(s[0:2]) a int(s[0:2]) int s[0:2] s 0:2 0 2 b=int(s[2:4]) b int(s[2:4]) int s[2:4] s 2:4 2 4 if 0<a<13:
  if 0<b<13:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0<b<13:
    print('YYMM')
  else:
    print('NA') 0<a<13 0<a 0 a 13 if 0<b<13:
    print('AMBIGUOUS')
  else:
    print('MMYY') 0<b<13 0<b 0 b 13 print('AMBIGUOUS') print 'AMBIGUOUS' print('MMYY') print 'MMYY' if 0<b<13:
    print('YYMM')
  else:
    print('NA') 0<b<13 0<b 0 b 13 print('YYMM') print 'YYMM' print('NA') print 'NA' a=int(s[0:2]) int(s[0:2]) a s=input() input() s b=int(s[2:4]) int(s[2:4]) b
s=input()
a=int(s[0:2])
b=int(s[2:4])
if 0<a<13:
  if 0<b<13:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0<b<13:
    print('YYMM')
  else:
    print('NA')