S = input()
if 0<int(S[0]+S[1])<13:	#MMかYY
  if 0<int(S[2]+S[3])<13:	#MMかYY
    print('AMBIGUOUS')
  else:	#YY
    print('MMYY')
else:	#YY
  if 0<int(S[2]+S[3])<13:	#MM
    print('YYMM')
  else:	#YY
    print('NA') S = input() S input() input if 0<int(S[0]+S[1])<13:	#MMかYY
  if 0<int(S[2]+S[3])<13:	#MMかYY
    print('AMBIGUOUS')
  else:	#YY
    print('MMYY')
else:	#YY
  if 0<int(S[2]+S[3])<13:	#MM
    print('YYMM')
  else:	#YY
    print('NA') 0<int(S[0]+S[1])<13 0<int(S[0]+S[1]) 0 int(S[0]+S[1]) int S[0]+S[1] S[0] S 0 S[1] S 1 13 if 0<int(S[2]+S[3])<13:	#MMかYY
    print('AMBIGUOUS')
  else:	#YY
    print('MMYY') 0<int(S[2]+S[3])<13 0<int(S[2]+S[3]) 0 int(S[2]+S[3]) int S[2]+S[3] S[2] S 2 S[3] S 3 13 print('AMBIGUOUS') print 'AMBIGUOUS' print('MMYY') print 'MMYY' if 0<int(S[2]+S[3])<13:	#MM
    print('YYMM')
  else:	#YY
    print('NA') 0<int(S[2]+S[3])<13 0<int(S[2]+S[3]) 0 int(S[2]+S[3]) int S[2]+S[3] S[2] S 2 S[3] S 3 13 print('YYMM') print 'YYMM' print('NA') print 'NA' S = input() input() S
S = input()
if 0<int(S[0]+S[1])<13:	#MMかYY
  if 0<int(S[2]+S[3])<13:	#MMかYY
    print('AMBIGUOUS')
  else:	#YY
    print('MMYY')
else:	#YY
  if 0<int(S[2]+S[3])<13:	#MM
    print('YYMM')
  else:	#YY
    print('NA')