z = input()
x = int(z[:2])
y = int(z[2:])

if (0<x <= 12):
      if (0<y<= 12):
            print("AMBIGUOUS")
      else:
            print("MMYY")
elif (0<y <= 12):
      if (0<x<= 12):
            print("AMBIGUOUS")
      else:
            print("YYMM")
else:
      print("NA")
 z = input() z input() input x = int(z[:2]) x int(z[:2]) int z[:2] z :2 2 y = int(z[2:]) y int(z[2:]) int z[2:] z 2: 2 if (0<x <= 12):
      if (0<y<= 12):
            print("AMBIGUOUS")
      else:
            print("MMYY")
elif (0<y <= 12):
      if (0<x<= 12):
            print("AMBIGUOUS")
      else:
            print("YYMM")
else:
      print("NA") 0<x <= 12 0<x 0 x 12 if (0<y<= 12):
            print("AMBIGUOUS")
      else:
            print("MMYY") 0<y<= 12 0<y 0 y 12 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" elif (0<y <= 12):
      if (0<x<= 12):
            print("AMBIGUOUS")
      else:
            print("YYMM") 0<y <= 12 0<y 0 y 12 if (0<x<= 12):
            print("AMBIGUOUS")
      else:
            print("YYMM") 0<x<= 12 0<x 0 x 12 print("AMBIGUOUS") print "AMBIGUOUS" print("YYMM") print "YYMM" print("NA") print "NA" z = input() input() z y = int(z[2:]) int(z[2:]) y x = int(z[:2]) int(z[:2]) x
z = input()
x = int(z[:2])
y = int(z[2:])

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

