s=int(input())
a=s//100
b=s%100
if a>0 and a<=12:
  if b>0 and b<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if b>0 and b<=12:
    print("YYMM")
  else:
    print("NA") s=int(input()) s int(input()) int input() input a=s//100 a s//100 s 100 b=s%100 b s%100 s 100 if a>0 and a<=12:
  if b>0 and b<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if b>0 and b<=12:
    print("YYMM")
  else:
    print("NA") a>0 and a<=12 a>0 a 0 a<=12 a 12 if b>0 and b<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY") b>0 and b<=12 b>0 b 0 b<=12 b 12 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" if b>0 and b<=12:
    print("YYMM")
  else:
    print("NA") b>0 and b<=12 b>0 b 0 b<=12 b 12 print("YYMM") print "YYMM" print("NA") print "NA" s=int(input()) int(input()) s b=s%100 s%100 b a=s//100 s//100 a
s=int(input())
a=s//100
b=s%100
if a>0 and a<=12:
  if b>0 and b<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if b>0 and b<=12:
    print("YYMM")
  else:
    print("NA")