S = int(input())

flag = [0, 0] # [YYMM, MMYY]
l = S // 100
r = S % 100
if 1<=r and r<=12:
  flag[0] += 1
if 1<=l and l<=12:
  flag[1] += 1
if flag == [0, 0]:
  print('NA')
elif flag == [0, 1]:
  print('MMYY')
elif flag == [1, 0]:
  print('YYMM')
elif flag == [1, 1]:
  print("AMBIGUOUS") S = int(input()) S int(input()) int input() input flag = [0, 0] flag [0, 0] 0 0 l = S // 100 l S // 100 S 100 r = S % 100 r S % 100 S 100 if 1<=r and r<=12:
  flag[0] += 1 1<=r and r<=12 1<=r 1 r r<=12 r 12 flag[0] += 1 flag[0] flag 0 1 if 1<=l and l<=12:
  flag[1] += 1 1<=l and l<=12 1<=l 1 l l<=12 l 12 flag[1] += 1 flag[1] flag 1 1 if flag == [0, 0]:
  print('NA')
elif flag == [0, 1]:
  print('MMYY')
elif flag == [1, 0]:
  print('YYMM')
elif flag == [1, 1]:
  print("AMBIGUOUS") flag == [0, 0] flag [0, 0] 0 0 print('NA') print 'NA' elif flag == [0, 1]:
  print('MMYY') flag == [0, 1] flag [0, 1] 0 1 print('MMYY') print 'MMYY' elif flag == [1, 0]:
  print('YYMM') flag == [1, 0] flag [1, 0] 1 0 print('YYMM') print 'YYMM' elif flag == [1, 1]:
  print("AMBIGUOUS") flag == [1, 1] flag [1, 1] 1 1 print("AMBIGUOUS") print "AMBIGUOUS" r = S % 100 S % 100 r S = int(input()) int(input()) S flag = [0, 0] [0, 0] flag l = S // 100 S // 100 l
S = int(input())

flag = [0, 0] # [YYMM, MMYY]
l = S // 100
r = S % 100
if 1<=r and r<=12:
  flag[0] += 1
if 1<=l and l<=12:
  flag[1] += 1
if flag == [0, 0]:
  print('NA')
elif flag == [0, 1]:
  print('MMYY')
elif flag == [1, 0]:
  print('YYMM')
elif flag == [1, 1]:
  print("AMBIGUOUS")