s = input()
f,b = int(s[:2]),int(s[2:])
if 1 <= f <= 12:
  if 1 <= b <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= b <= 12:
    print("YYMM")
  else:
    print("NA") s = input() s input() input f,b = int(s[:2]),int(s[2:]) f int(s[:2]) int s[:2] s :2 2 b int(s[2:]) int s[2:] s 2: 2 if 1 <= f <= 12:
  if 1 <= b <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= b <= 12:
    print("YYMM")
  else:
    print("NA") 1 <= f <= 12 1 <= f 1 f 12 if 1 <= b <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY") 1 <= b <= 12 1 <= b 1 b 12 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" if 1 <= b <= 12:
    print("YYMM")
  else:
    print("NA") 1 <= b <= 12 1 <= b 1 b 12 print("YYMM") print "YYMM" print("NA") print "NA" b = int(s[:2]),int(s[2:]) int(s[2:]) b f,b = int(s[:2]),int(s[2:]) int(s[:2]) f s = input() input() s
s = input()
f,b = int(s[:2]),int(s[2:])
if 1 <= f <= 12:
  if 1 <= b <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= b <= 12:
    print("YYMM")
  else:
    print("NA")