s = input()

if ((int(s[0])==0 and 1<=int(s[1])<=9)  or (int(s[0]) == 1 and 0<=int(s[1])<=2)) and ((int(s[2])==0 and 1<=int(s[3])<=9)  or (int(s[2]) == 1 and 0<=int(s[3])<=2) ):
  print("AMBIGUOUS")
elif (int(s[0])==0 and 1 <=int(s[1])<=9)  or (int(s[0]) == 1 and 0<=int(s[1])<=2):
  print("MMYY")
elif (int(s[2])==0 and 1 <=int(s[3])<=9)  or (int(s[2]) == 1 and 0<=int(s[3])<=2):
  print("YYMM")
else:
  print("NA") s = input() s input() input if ((int(s[0])==0 and 1<=int(s[1])<=9)  or (int(s[0]) == 1 and 0<=int(s[1])<=2)) and ((int(s[2])==0 and 1<=int(s[3])<=9)  or (int(s[2]) == 1 and 0<=int(s[3])<=2) ):
  print("AMBIGUOUS")
elif (int(s[0])==0 and 1 <=int(s[1])<=9)  or (int(s[0]) == 1 and 0<=int(s[1])<=2):
  print("MMYY")
elif (int(s[2])==0 and 1 <=int(s[3])<=9)  or (int(s[2]) == 1 and 0<=int(s[3])<=2):
  print("YYMM")
else:
  print("NA") ((int(s[0])==0 and 1<=int(s[1])<=9)  or (int(s[0]) == 1 and 0<=int(s[1])<=2)) and ((int(s[2])==0 and 1<=int(s[3])<=9)  or (int(s[2]) == 1 and 0<=int(s[3])<=2) ) (int(s[0])==0 and 1<=int(s[1])<=9)  or (int(s[0]) == 1 and 0<=int(s[1])<=2) int(s[0])==0 and 1<=int(s[1])<=9 int(s[0])==0 int(s[0]) int s[0] s 0 0 1<=int(s[1])<=9 1<=int(s[1]) 1 int(s[1]) int s[1] s 1 9 int(s[0]) == 1 and 0<=int(s[1])<=2 int(s[0]) == 1 int(s[0]) int s[0] s 0 1 0<=int(s[1])<=2 0<=int(s[1]) 0 int(s[1]) int s[1] s 1 2 (int(s[2])==0 and 1<=int(s[3])<=9)  or (int(s[2]) == 1 and 0<=int(s[3])<=2) int(s[2])==0 and 1<=int(s[3])<=9 int(s[2])==0 int(s[2]) int s[2] s 2 0 1<=int(s[3])<=9 1<=int(s[3]) 1 int(s[3]) int s[3] s 3 9 int(s[2]) == 1 and 0<=int(s[3])<=2 int(s[2]) == 1 int(s[2]) int s[2] s 2 1 0<=int(s[3])<=2 0<=int(s[3]) 0 int(s[3]) int s[3] s 3 2 print("AMBIGUOUS") print "AMBIGUOUS" elif (int(s[0])==0 and 1 <=int(s[1])<=9)  or (int(s[0]) == 1 and 0<=int(s[1])<=2):
  print("MMYY") (int(s[0])==0 and 1 <=int(s[1])<=9)  or (int(s[0]) == 1 and 0<=int(s[1])<=2) int(s[0])==0 and 1 <=int(s[1])<=9 int(s[0])==0 int(s[0]) int s[0] s 0 0 1 <=int(s[1])<=9 1 <=int(s[1]) 1 int(s[1]) int s[1] s 1 9 int(s[0]) == 1 and 0<=int(s[1])<=2 int(s[0]) == 1 int(s[0]) int s[0] s 0 1 0<=int(s[1])<=2 0<=int(s[1]) 0 int(s[1]) int s[1] s 1 2 print("MMYY") print "MMYY" elif (int(s[2])==0 and 1 <=int(s[3])<=9)  or (int(s[2]) == 1 and 0<=int(s[3])<=2):
  print("YYMM") (int(s[2])==0 and 1 <=int(s[3])<=9)  or (int(s[2]) == 1 and 0<=int(s[3])<=2) int(s[2])==0 and 1 <=int(s[3])<=9 int(s[2])==0 int(s[2]) int s[2] s 2 0 1 <=int(s[3])<=9 1 <=int(s[3]) 1 int(s[3]) int s[3] s 3 9 int(s[2]) == 1 and 0<=int(s[3])<=2 int(s[2]) == 1 int(s[2]) int s[2] s 2 1 0<=int(s[3])<=2 0<=int(s[3]) 0 int(s[3]) int s[3] s 3 2 print("YYMM") print "YYMM" print("NA") print "NA" s = input() input() s
s = input()

if ((int(s[0])==0 and 1<=int(s[1])<=9)  or (int(s[0]) == 1 and 0<=int(s[1])<=2)) and ((int(s[2])==0 and 1<=int(s[3])<=9)  or (int(s[2]) == 1 and 0<=int(s[3])<=2) ):
  print("AMBIGUOUS")
elif (int(s[0])==0 and 1 <=int(s[1])<=9)  or (int(s[0]) == 1 and 0<=int(s[1])<=2):
  print("MMYY")
elif (int(s[2])==0 and 1 <=int(s[3])<=9)  or (int(s[2]) == 1 and 0<=int(s[3])<=2):
  print("YYMM")
else:
  print("NA")
