S = input()
A = int(S[:2])
B = int(S[2:])

if 1<=A<=12 and 1<=B<=12:
  print("AMBIGUOUS")
elif 1<=A<=12:
  print("MMYY")
elif 1<=B<=12:
  print("YYMM")
else:
  print("NA") S = input() S input() input A = int(S[:2]) A int(S[:2]) int S[:2] S :2 2 B = int(S[2:]) B int(S[2:]) int S[2:] S 2: 2 if 1<=A<=12 and 1<=B<=12:
  print("AMBIGUOUS")
elif 1<=A<=12:
  print("MMYY")
elif 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:
  print("MMYY") 1<=A<=12 1<=A 1 A 12 print("MMYY") print "MMYY" elif 1<=B<=12:
  print("YYMM") 1<=B<=12 1<=B 1 B 12 print("YYMM") print "YYMM" print("NA") print "NA" A = int(S[:2]) int(S[:2]) A S = input() input() S B = int(S[2:]) int(S[2:]) B
S = input()
A = int(S[:2])
B = int(S[2:])

if 1<=A<=12 and 1<=B<=12:
  print("AMBIGUOUS")
elif 1<=A<=12:
  print("MMYY")
elif 1<=B<=12:
  print("YYMM")
else:
  print("NA")