s = list(input())

a = int(s[0]+s[1])
b = int(s[2]+s[3])

if  1<=a<=12 and 1<=b<=12:
  print('AMBIGUOUS')
elif (a>12 or a==0) and 1<=b<=12:
  print('YYMM')
elif (b>12 or b==0) and 1<=a<=12:
  print('MMYY')
elif (a>12 or a==0) and (b>12 or b==0):
  print('NA') s = list(input()) s list(input()) list input() input a = int(s[0]+s[1]) a int(s[0]+s[1]) int s[0]+s[1] s[0] s 0 s[1] s 1 b = int(s[2]+s[3]) b int(s[2]+s[3]) int s[2]+s[3] s[2] s 2 s[3] s 3 if  1<=a<=12 and 1<=b<=12:
  print('AMBIGUOUS')
elif (a>12 or a==0) and 1<=b<=12:
  print('YYMM')
elif (b>12 or b==0) and 1<=a<=12:
  print('MMYY')
elif (a>12 or a==0) and (b>12 or b==0):
  print('NA') 1<=a<=12 and 1<=b<=12 1<=a<=12 1<=a 1 a 12 1<=b<=12 1<=b 1 b 12 print('AMBIGUOUS') print 'AMBIGUOUS' elif (a>12 or a==0) and 1<=b<=12:
  print('YYMM') (a>12 or a==0) and 1<=b<=12 a>12 or a==0 a>12 a 12 a==0 a 0 1<=b<=12 1<=b 1 b 12 print('YYMM') print 'YYMM' elif (b>12 or b==0) and 1<=a<=12:
  print('MMYY') (b>12 or b==0) and 1<=a<=12 b>12 or b==0 b>12 b 12 b==0 b 0 1<=a<=12 1<=a 1 a 12 print('MMYY') print 'MMYY' elif (a>12 or a==0) and (b>12 or b==0):
  print('NA') (a>12 or a==0) and (b>12 or b==0) a>12 or a==0 a>12 a 12 a==0 a 0 b>12 or b==0 b>12 b 12 b==0 b 0 print('NA') print 'NA' b = int(s[2]+s[3]) int(s[2]+s[3]) b s = list(input()) list(input()) s a = int(s[0]+s[1]) int(s[0]+s[1]) a
s = list(input())

a = int(s[0]+s[1])
b = int(s[2]+s[3])

if  1<=a<=12 and 1<=b<=12:
  print('AMBIGUOUS')
elif (a>12 or a==0) and 1<=b<=12:
  print('YYMM')
elif (b>12 or b==0) and 1<=a<=12:
  print('MMYY')
elif (a>12 or a==0) and (b>12 or b==0):
  print('NA')