s=input()
a=int(s[:2])
b=int(s[2:])
ac=0
bc=0
if 0<a and a<13:
  ac=1
if 0<b and b<13:
  bc=1
  
if ac and bc:
  print("AMBIGUOUS")
elif ac:
  print("MMYY")
elif bc:
  print("YYMM")
else:
  print("NA") s=input() s input() input a=int(s[:2]) a int(s[:2]) int s[:2] s :2 2 b=int(s[2:]) b int(s[2:]) int s[2:] s 2: 2 ac=0 ac 0 bc=0 bc 0 if 0<a and a<13:
  ac=1 0<a and a<13 0<a 0 a a<13 a 13 ac=1 ac 1 if 0<b and b<13:
  bc=1
   0<b and b<13 0<b 0 b b<13 b 13 bc=1 bc 1 if ac and bc:
  print("AMBIGUOUS")
elif ac:
  print("MMYY")
elif bc:
  print("YYMM")
else:
  print("NA") ac and bc ac bc print("AMBIGUOUS") print "AMBIGUOUS" elif ac:
  print("MMYY") ac print("MMYY") print "MMYY" elif bc:
  print("YYMM") bc print("YYMM") print "YYMM" print("NA") print "NA" ac=1 1 ac bc=1 1 bc s=input() input() s a=int(s[:2]) int(s[:2]) a b=int(s[2:]) int(s[2:]) b ac=0 0 ac bc=0 0 bc
s=input()
a=int(s[:2])
b=int(s[2:])
ac=0
bc=0
if 0<a and a<13:
  ac=1
if 0<b and b<13:
  bc=1
  
if ac and bc:
  print("AMBIGUOUS")
elif ac:
  print("MMYY")
elif bc:
  print("YYMM")
else:
  print("NA")