s=int(input())
a=s//100
b=s%100
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12 and (b>12 or b==0):
  print("MMYY")
elif (a==0 or a>12) and 1<=b<=12:
  print("YYMM")
else:
  print("NA") s=int(input()) s int(input()) int input() input a=s//100 a s//100 s 100 b=s%100 b s%100 s 100 if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12 and (b>12 or b==0):
  print("MMYY")
elif (a==0 or a>12) and 1<=b<=12:
  print("YYMM")
else:
  print("NA") 1<=a<=12 and 1<=b<=12 1<=a<=12 1<=a 1 a 12 1<=b<=12 1<=b 1 b 12 print("AMBIGUOUS") print "AMBIGUOUS" elif 1<=a<=12 and (b>12 or b==0):
  print("MMYY") 1<=a<=12 and (b>12 or b==0) 1<=a<=12 1<=a 1 a 12 b>12 or b==0 b>12 b 12 b==0 b 0 print("MMYY") print "MMYY" elif (a==0 or a>12) and 1<=b<=12:
  print("YYMM") (a==0 or a>12) and 1<=b<=12 a==0 or a>12 a==0 a 0 a>12 a 12 1<=b<=12 1<=b 1 b 12 print("YYMM") print "YYMM" print("NA") print "NA" b=s%100 s%100 b s=int(input()) int(input()) s a=s//100 s//100 a
s=int(input())
a=s//100
b=s%100
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12 and (b>12 or b==0):
  print("MMYY")
elif (a==0 or a>12) and 1<=b<=12:
  print("YYMM")
else:
  print("NA")