s = input()
ans = 0
for i in range(0,3,2):
  if s[i] == "0" and s[i+1] == "0":
    continue
  elif s[i] == "0":
    ans += i+1
  elif (s[i] == "1" and s[i+1] == "0") or (s[i] == "1" and s[i+1] == "1") or (s[i] == "1" and s[i+1] == "2"):
    ans += i+1
if ans == 1:
  print("MMYY")
elif ans == 3:
  print("YYMM")
elif ans == 4:
  print("AMBIGUOUS")
else:
  print("NA") s = input() s input() input ans = 0 ans 0 for i in range(0,3,2):
  if s[i] == "0" and s[i+1] == "0":
    continue
  elif s[i] == "0":
    ans += i+1
  elif (s[i] == "1" and s[i+1] == "0") or (s[i] == "1" and s[i+1] == "1") or (s[i] == "1" and s[i+1] == "2"):
    ans += i+1 i range(0,3,2) range 0 3 2 if s[i] == "0" and s[i+1] == "0":
    continue
  elif s[i] == "0":
    ans += i+1
  elif (s[i] == "1" and s[i+1] == "0") or (s[i] == "1" and s[i+1] == "1") or (s[i] == "1" and s[i+1] == "2"):
    ans += i+1 s[i] == "0" and s[i+1] == "0" s[i] == "0" s[i] s i "0" s[i+1] == "0" s[i+1] s i+1 i 1 "0" continue elif s[i] == "0":
    ans += i+1
   s[i] == "0" s[i] s i "0" ans += i+1 ans i+1 i 1 elif (s[i] == "1" and s[i+1] == "0") or (s[i] == "1" and s[i+1] == "1") or (s[i] == "1" and s[i+1] == "2"):
    ans += i+1 (s[i] == "1" and s[i+1] == "0") or (s[i] == "1" and s[i+1] == "1") or (s[i] == "1" and s[i+1] == "2") (s[i] == "1" and s[i+1] == "0") or (s[i] == "1" and s[i+1] == "1") s[i] == "1" and s[i+1] == "0" s[i] == "1" s[i] s i "1" s[i+1] == "0" s[i+1] s i+1 i 1 "0" s[i] == "1" and s[i+1] == "1" s[i] == "1" s[i] s i "1" s[i+1] == "1" s[i+1] s i+1 i 1 "1" s[i] == "1" and s[i+1] == "2" s[i] == "1" s[i] s i "1" s[i+1] == "2" s[i+1] s i+1 i 1 "2" ans += i+1 ans i+1 i 1 if ans == 1:
  print("MMYY")
elif ans == 3:
  print("YYMM")
elif ans == 4:
  print("AMBIGUOUS")
else:
  print("NA") ans == 1 ans 1 print("MMYY") print "MMYY" elif ans == 3:
  print("YYMM") ans == 3 ans 3 print("YYMM") print "YYMM" elif ans == 4:
  print("AMBIGUOUS") ans == 4 ans 4 print("AMBIGUOUS") print "AMBIGUOUS" print("NA") print "NA" s = input() input() s ans += i+1 i+1 ans ans += i+1 i+1 ans ans = 0 0 ans
s = input()
ans = 0
for i in range(0,3,2):
  if s[i] == "0" and s[i+1] == "0":
    continue
  elif s[i] == "0":
    ans += i+1
  elif (s[i] == "1" and s[i+1] == "0") or (s[i] == "1" and s[i+1] == "1") or (s[i] == "1" and s[i+1] == "2"):
    ans += i+1
if ans == 1:
  print("MMYY")
elif ans == 3:
  print("YYMM")
elif ans == 4:
  print("AMBIGUOUS")
else:
  print("NA")