s = (input())
a= s[0:2]
b= s[2:4]
a = int(a)
b= int(b)
if a == 0 or b == 0:
  if b!= 0 and b<13:
    print('YYMM')
  elif a!= 0 and a<13:
    print('MMYY')
  else:
    print('NA')
elif a<13 or b<13:
  if a>12:
    print('YYMM')
  elif b>12:
    print('MMYY')
  else:
    print('AMBIGUOUS')
else:
  print('NA') s = (input()) s input() input a= s[0:2] a s[0:2] s 0:2 0 2 b= s[2:4] b s[2:4] s 2:4 2 4 a = int(a) a int(a) int a b= int(b) b int(b) int b if a == 0 or b == 0:
  if b!= 0 and b<13:
    print('YYMM')
  elif a!= 0 and a<13:
    print('MMYY')
  else:
    print('NA')
elif a<13 or b<13:
  if a>12:
    print('YYMM')
  elif b>12:
    print('MMYY')
  else:
    print('AMBIGUOUS')
else:
  print('NA') a == 0 or b == 0 a == 0 a 0 b == 0 b 0 if b!= 0 and b<13:
    print('YYMM')
  elif a!= 0 and a<13:
    print('MMYY')
  else:
    print('NA') b!= 0 and b<13 b!= 0 b 0 b<13 b 13 print('YYMM') print 'YYMM' elif a!= 0 and a<13:
    print('MMYY')
   a!= 0 and a<13 a!= 0 a 0 a<13 a 13 print('MMYY') print 'MMYY' print('NA') print 'NA' elif a<13 or b<13:
  if a>12:
    print('YYMM')
  elif b>12:
    print('MMYY')
  else:
    print('AMBIGUOUS') a<13 or b<13 a<13 a 13 b<13 b 13 if a>12:
    print('YYMM')
  elif b>12:
    print('MMYY')
  else:
    print('AMBIGUOUS') a>12 a 12 print('YYMM') print 'YYMM' elif b>12:
    print('MMYY')
   b>12 b 12 print('MMYY') print 'MMYY' print('AMBIGUOUS') print 'AMBIGUOUS' print('NA') print 'NA' b= s[2:4] s[2:4] b a= s[0:2] s[0:2] a a = int(a) int(a) a s = (input()) input() s b= int(b) int(b) b
s = (input())
a= s[0:2]
b= s[2:4]
a = int(a)
b= int(b)
if a == 0 or b == 0:
  if b!= 0 and b<13:
    print('YYMM')
  elif a!= 0 and a<13:
    print('MMYY')
  else:
    print('NA')
elif a<13 or b<13:
  if a>12:
    print('YYMM')
  elif b>12:
    print('MMYY')
  else:
    print('AMBIGUOUS')
else:
  print('NA')