S = input()
L, R =  map(int, [S[:2], S[2:]])
 
if 1 <= L <= 12 and 1 <= R <= 12:
  print("AMBIGUOUS")
elif 1 <= L <= 12 and (R == 0 or R > 12):
  print("MMYY")
elif (L == 0 or L > 12) and 1 <= R <= 12:
  print("YYMM")
else:
  print("NA") S = input() S input() input L, R =  map(int, [S[:2], S[2:]]) L map(int, [S[:2], S[2:]]) map int [S[:2], S[2:]] S[:2] S :2 2 S[2:] S 2: 2 R if 1 <= L <= 12 and 1 <= R <= 12:
  print("AMBIGUOUS")
elif 1 <= L <= 12 and (R == 0 or R > 12):
  print("MMYY")
elif (L == 0 or L > 12) and 1 <= R <= 12:
  print("YYMM")
else:
  print("NA") 1 <= L <= 12 and 1 <= R <= 12 1 <= L <= 12 1 <= L 1 L 12 1 <= R <= 12 1 <= R 1 R 12 print("AMBIGUOUS") print "AMBIGUOUS" elif 1 <= L <= 12 and (R == 0 or R > 12):
  print("MMYY") 1 <= L <= 12 and (R == 0 or R > 12) 1 <= L <= 12 1 <= L 1 L 12 R == 0 or R > 12 R == 0 R 0 R > 12 R 12 print("MMYY") print "MMYY" elif (L == 0 or L > 12) and 1 <= R <= 12:
  print("YYMM") (L == 0 or L > 12) and 1 <= R <= 12 L == 0 or L > 12 L == 0 L 0 L > 12 L 12 1 <= R <= 12 1 <= R 1 R 12 print("YYMM") print "YYMM" print("NA") print "NA" L, R =  map(int, [S[:2], S[2:]]) map(int, [S[:2], S[2:]]) L R =  map(int, [S[:2], S[2:]]) map(int, [S[:2], S[2:]]) R S = input() input() S
S = input()
L, R =  map(int, [S[:2], S[2:]])
 
if 1 <= L <= 12 and 1 <= R <= 12:
  print("AMBIGUOUS")
elif 1 <= L <= 12 and (R == 0 or R > 12):
  print("MMYY")
elif (L == 0 or L > 12) and 1 <= R <= 12:
  print("YYMM")
else:
  print("NA")