s = input()
x = int(s) // 100
y = int(s) % 100
if 1 <= x <= 12:
  if 1 <= y <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= y <= 12:
    print("YYMM")
  else:
    print("NA") s = input() s input() input x = int(s) // 100 x int(s) // 100 int(s) int s 100 y = int(s) % 100 y int(s) % 100 int(s) int s 100 if 1 <= x <= 12:
  if 1 <= y <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= y <= 12:
    print("YYMM")
  else:
    print("NA") 1 <= x <= 12 1 <= x 1 x 12 if 1 <= y <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY") 1 <= y <= 12 1 <= y 1 y 12 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" if 1 <= y <= 12:
    print("YYMM")
  else:
    print("NA") 1 <= y <= 12 1 <= y 1 y 12 print("YYMM") print "YYMM" print("NA") print "NA" y = int(s) % 100 int(s) % 100 y s = input() input() s x = int(s) // 100 int(s) // 100 x
s = input()
x = int(s) // 100
y = int(s) % 100
if 1 <= x <= 12:
  if 1 <= y <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= y <= 12:
    print("YYMM")
  else:
    print("NA")