s=input()
ym=True if 0 < int(s[2:]) < 13 else False
my=True if 0 < int(s[:2]) < 13 else False
if my and ym:
  print('AMBIGUOUS')
elif my:
  print('MMYY')
elif ym:
  print('YYMM')
else:
  print('NA') s=input() s input() input ym=True if 0 < int(s[2:]) < 13 else False ym True if 0 < int(s[2:]) < 13 else False 0 < int(s[2:]) < 13 0 < int(s[2:]) 0 int(s[2:]) int s[2:] s 2: 2 13 True False my=True if 0 < int(s[:2]) < 13 else False my True if 0 < int(s[:2]) < 13 else False 0 < int(s[:2]) < 13 0 < int(s[:2]) 0 int(s[:2]) int s[:2] s :2 2 13 True False if my and ym:
  print('AMBIGUOUS')
elif my:
  print('MMYY')
elif ym:
  print('YYMM')
else:
  print('NA') my and ym my ym print('AMBIGUOUS') print 'AMBIGUOUS' elif my:
  print('MMYY') my print('MMYY') print 'MMYY' elif ym:
  print('YYMM') ym print('YYMM') print 'YYMM' print('NA') print 'NA' my=True if 0 < int(s[:2]) < 13 else False True if 0 < int(s[:2]) < 13 else False my s=input() input() s ym=True if 0 < int(s[2:]) < 13 else False True if 0 < int(s[2:]) < 13 else False ym
s=input()
ym=True if 0 < int(s[2:]) < 13 else False
my=True if 0 < int(s[:2]) < 13 else False
if my and ym:
  print('AMBIGUOUS')
elif my:
  print('MMYY')
elif ym:
  print('YYMM')
else:
  print('NA')