S =int(input())
a = S // 100
b = S % 100
if 0 < a < 13 :
  if 0 < b < 13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0 < b < 13:
    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 0 < a < 13 :
  if 0 < b < 13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0 < b < 13:
    print("YYMM")
  else:
    print("NA") 0 < a < 13 0 < a 0 a 13 if 0 < b < 13:
    print("AMBIGUOUS")
  else:
    print("MMYY") 0 < b < 13 0 < b 0 b 13 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" if 0 < b < 13:
    print("YYMM")
  else:
    print("NA") 0 < b < 13 0 < b 0 b 13 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 0 < a < 13 :
  if 0 < b < 13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0 < b < 13:
    print("YYMM")
  else:
    print("NA")