n = list(input())
x = int(n[0]+n[1])
y = int(n[2]+n[3])

if 1 <= x and x <= 12:
  if 1 <= y and y <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
elif 1 <= y and y <= 12:
  print("YYMM")
else:
  print("NA") n = list(input()) n list(input()) list input() input x = int(n[0]+n[1]) x int(n[0]+n[1]) int n[0]+n[1] n[0] n 0 n[1] n 1 y = int(n[2]+n[3]) y int(n[2]+n[3]) int n[2]+n[3] n[2] n 2 n[3] n 3 if 1 <= x and x <= 12:
  if 1 <= y and y <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
elif 1 <= y and y <= 12:
  print("YYMM")
else:
  print("NA") 1 <= x and x <= 12 1 <= x 1 x x <= 12 x 12 if 1 <= y and y <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY") 1 <= y and y <= 12 1 <= y 1 y y <= 12 y 12 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" elif 1 <= y and y <= 12:
  print("YYMM") 1 <= y and y <= 12 1 <= y 1 y y <= 12 y 12 print("YYMM") print "YYMM" print("NA") print "NA" n = list(input()) list(input()) n y = int(n[2]+n[3]) int(n[2]+n[3]) y x = int(n[0]+n[1]) int(n[0]+n[1]) x
n = list(input())
x = int(n[0]+n[1])
y = int(n[2]+n[3])

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