S = input()
MM = ["01","02","03","04","05","06","07","08","09","10","11","12"]

if S[:2] in MM and S[2:] in MM:
  print("AMBIGUOUS")
elif S[:2] in MM:
  print("MMYY")
elif S[2:] in MM:
  print("YYMM")
else:
  print("NA") S = input() S input() input MM = ["01","02","03","04","05","06","07","08","09","10","11","12"] MM ["01","02","03","04","05","06","07","08","09","10","11","12"] "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" if S[:2] in MM and S[2:] in MM:
  print("AMBIGUOUS")
elif S[:2] in MM:
  print("MMYY")
elif S[2:] in MM:
  print("YYMM")
else:
  print("NA") S[:2] in MM and S[2:] in MM S[:2] in MM S[:2] S :2 2 MM S[2:] in MM S[2:] S 2: 2 MM print("AMBIGUOUS") print "AMBIGUOUS" elif S[:2] in MM:
  print("MMYY") S[:2] in MM S[:2] S :2 2 MM print("MMYY") print "MMYY" elif S[2:] in MM:
  print("YYMM") S[2:] in MM S[2:] S 2: 2 MM print("YYMM") print "YYMM" print("NA") print "NA" S = input() input() S MM = ["01","02","03","04","05","06","07","08","09","10","11","12"] ["01","02","03","04","05","06","07","08","09","10","11","12"] MM
S = input()
MM = ["01","02","03","04","05","06","07","08","09","10","11","12"]

if S[:2] in MM and S[2:] in MM:
  print("AMBIGUOUS")
elif S[:2] in MM:
  print("MMYY")
elif S[2:] in MM:
  print("YYMM")
else:
  print("NA")