a=input()
b=int(a[0]+a[1])
c=int(a[2]+a[3])
if 1<=b<=12:
  if 1<=c<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=c<=12:
    print("YYMM")
  else:
    print("NA") a=input() a input() input b=int(a[0]+a[1]) b int(a[0]+a[1]) int a[0]+a[1] a[0] a 0 a[1] a 1 c=int(a[2]+a[3]) c int(a[2]+a[3]) int a[2]+a[3] a[2] a 2 a[3] a 3 if 1<=b<=12:
  if 1<=c<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=c<=12:
    print("YYMM")
  else:
    print("NA") 1<=b<=12 1<=b 1 b 12 if 1<=c<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY") 1<=c<=12 1<=c 1 c 12 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" if 1<=c<=12:
    print("YYMM")
  else:
    print("NA") 1<=c<=12 1<=c 1 c 12 print("YYMM") print "YYMM" print("NA") print "NA" b=int(a[0]+a[1]) int(a[0]+a[1]) b c=int(a[2]+a[3]) int(a[2]+a[3]) c a=input() input() a
a=input()
b=int(a[0]+a[1])
c=int(a[2]+a[3])
if 1<=b<=12:
  if 1<=c<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=c<=12:
    print("YYMM")
  else:
    print("NA")