S = list(input())
S1 = S[0] + S[1]
S2 = S[2] + S[3]
S1 = int(S1)
S2 = int(S2)

if 1 <= S1 <= 12 and 1 <= S2 <= 12:
  print('AMBIGUOUS')
elif (1 > S1 or S1 > 12) and 1 <= S2 <= 12:
  print('YYMM')
elif (1 > S2 or S2 > 12) and 1 <= S1 <= 12:
  print('MMYY')
else:
  print('NA') S = list(input()) S list(input()) list input() input S1 = S[0] + S[1] S1 S[0] + S[1] S[0] S 0 S[1] S 1 S2 = S[2] + S[3] S2 S[2] + S[3] S[2] S 2 S[3] S 3 S1 = int(S1) S1 int(S1) int S1 S2 = int(S2) S2 int(S2) int S2 if 1 <= S1 <= 12 and 1 <= S2 <= 12:
  print('AMBIGUOUS')
elif (1 > S1 or S1 > 12) and 1 <= S2 <= 12:
  print('YYMM')
elif (1 > S2 or S2 > 12) and 1 <= S1 <= 12:
  print('MMYY')
else:
  print('NA') 1 <= S1 <= 12 and 1 <= S2 <= 12 1 <= S1 <= 12 1 <= S1 1 S1 12 1 <= S2 <= 12 1 <= S2 1 S2 12 print('AMBIGUOUS') print 'AMBIGUOUS' elif (1 > S1 or S1 > 12) and 1 <= S2 <= 12:
  print('YYMM') (1 > S1 or S1 > 12) and 1 <= S2 <= 12 1 > S1 or S1 > 12 1 > S1 1 S1 S1 > 12 S1 12 1 <= S2 <= 12 1 <= S2 1 S2 12 print('YYMM') print 'YYMM' elif (1 > S2 or S2 > 12) and 1 <= S1 <= 12:
  print('MMYY') (1 > S2 or S2 > 12) and 1 <= S1 <= 12 1 > S2 or S2 > 12 1 > S2 1 S2 S2 > 12 S2 12 1 <= S1 <= 12 1 <= S1 1 S1 12 print('MMYY') print 'MMYY' print('NA') print 'NA' S2 = int(S2) int(S2) S2 S1 = int(S1) int(S1) S1 S2 = S[2] + S[3] S[2] + S[3] S2 S = list(input()) list(input()) S S1 = S[0] + S[1] S[0] + S[1] S1
S = list(input())
S1 = S[0] + S[1]
S2 = S[2] + S[3]
S1 = int(S1)
S2 = int(S2)

if 1 <= S1 <= 12 and 1 <= S2 <= 12:
  print('AMBIGUOUS')
elif (1 > S1 or S1 > 12) and 1 <= S2 <= 12:
  print('YYMM')
elif (1 > S2 or S2 > 12) and 1 <= S1 <= 12:
  print('MMYY')
else:
  print('NA')
