S = input()
flagA = False
flagB = False
if 1 <= int(S[2:4])<= 12:
  flagB = True
if 1 <= int(S[0:2])<= 12:
  flagA = True
if flagA and flagB:
  print("AMBIGUOUS")
elif flagA and not flagB:
  print("MMYY")
elif flagB and not flagA:
  print("YYMM")
else:
  print("NA") S = input() S input() input flagA = False flagA False flagB = False flagB False if 1 <= int(S[2:4])<= 12:
  flagB = True 1 <= int(S[2:4])<= 12 1 <= int(S[2:4]) 1 int(S[2:4]) int S[2:4] S 2:4 2 4 12 flagB = True flagB True if 1 <= int(S[0:2])<= 12:
  flagA = True 1 <= int(S[0:2])<= 12 1 <= int(S[0:2]) 1 int(S[0:2]) int S[0:2] S 0:2 0 2 12 flagA = True flagA True if flagA and flagB:
  print("AMBIGUOUS")
elif flagA and not flagB:
  print("MMYY")
elif flagB and not flagA:
  print("YYMM")
else:
  print("NA") flagA and flagB flagA flagB print("AMBIGUOUS") print "AMBIGUOUS" elif flagA and not flagB:
  print("MMYY") flagA and not flagB flagA not flagB flagB print("MMYY") print "MMYY" elif flagB and not flagA:
  print("YYMM") flagB and not flagA flagB not flagA flagA print("YYMM") print "YYMM" print("NA") print "NA" flagA = False False flagA flagA = True True flagA flagB = True True flagB S = input() input() S flagB = False False flagB
S = input()
flagA = False
flagB = False
if 1 <= int(S[2:4])<= 12:
  flagB = True
if 1 <= int(S[0:2])<= 12:
  flagA = True
if flagA and flagB:
  print("AMBIGUOUS")
elif flagA and not flagB:
  print("MMYY")
elif flagB and not flagA:
  print("YYMM")
else:
  print("NA")