S = int(input())
 
L = S // 100 # 前半2桁
R = S % 100 # 後半2桁
 
if 1 <= L <= 12:
  if 1 <= R <= 12: print('AMBIGUOUS')
  else: print('MMYY')
else:
  if 1 <= R <= 12: print('YYMM')
  else: print('NA') S = int(input()) S int(input()) int input() input L = S // 100 L S // 100 S 100 R = S % 100 R S % 100 S 100 if 1 <= L <= 12:
  if 1 <= R <= 12: print('AMBIGUOUS')
  else: print('MMYY')
else:
  if 1 <= R <= 12: print('YYMM')
  else: print('NA') 1 <= L <= 12 1 <= L 1 L 12 if 1 <= R <= 12: print('AMBIGUOUS')
  else: print('MMYY') 1 <= R <= 12 1 <= R 1 R 12 if 1 <= R <= 12: print('YYMM')
  else: print('NA') 1 <= R <= 12 1 <= R 1 R 12 R = S % 100 S % 100 R S = int(input()) int(input()) S L = S // 100 S // 100 L
S = int(input())
 
L = S // 100 # 前半2桁
R = S % 100 # 後半2桁
 
if 1 <= L <= 12:
  if 1 <= R <= 12: print('AMBIGUOUS')
  else: print('MMYY')
else:
  if 1 <= R <= 12: print('YYMM')
  else: print('NA')