n = input()
ans = 0
if 1 <= int(n[0:2]) <= 12 and 0 <= int(n[2:4]) <= 99:
  ans += 1
if 0 <= int(n[0:2]) <= 99 and 1 <= int(n[2:4]) <= 12:
  ans += 3
if ans == 1:
  print('MMYY')
elif ans == 3:
  print('YYMM')
elif ans == 4:
  print('AMBIGUOUS')
else:
  print('NA') n = input() n input() input ans = 0 ans 0 if 1 <= int(n[0:2]) <= 12 and 0 <= int(n[2:4]) <= 99:
  ans += 1 1 <= int(n[0:2]) <= 12 and 0 <= int(n[2:4]) <= 99 1 <= int(n[0:2]) <= 12 1 <= int(n[0:2]) 1 int(n[0:2]) int n[0:2] n 0:2 0 2 12 0 <= int(n[2:4]) <= 99 0 <= int(n[2:4]) 0 int(n[2:4]) int n[2:4] n 2:4 2 4 99 ans += 1 ans 1 if 0 <= int(n[0:2]) <= 99 and 1 <= int(n[2:4]) <= 12:
  ans += 3 0 <= int(n[0:2]) <= 99 and 1 <= int(n[2:4]) <= 12 0 <= int(n[0:2]) <= 99 0 <= int(n[0:2]) 0 int(n[0:2]) int n[0:2] n 0:2 0 2 99 1 <= int(n[2:4]) <= 12 1 <= int(n[2:4]) 1 int(n[2:4]) int n[2:4] n 2:4 2 4 12 ans += 3 ans 3 if ans == 1:
  print('MMYY')
elif ans == 3:
  print('YYMM')
elif ans == 4:
  print('AMBIGUOUS')
else:
  print('NA') ans == 1 ans 1 print('MMYY') print 'MMYY' elif ans == 3:
  print('YYMM') ans == 3 ans 3 print('YYMM') print 'YYMM' elif ans == 4:
  print('AMBIGUOUS') ans == 4 ans 4 print('AMBIGUOUS') print 'AMBIGUOUS' print('NA') print 'NA' n = input() input() n ans = 0 0 ans ans += 3 3 ans ans += 1 1 ans
n = input()
ans = 0
if 1 <= int(n[0:2]) <= 12 and 0 <= int(n[2:4]) <= 99:
  ans += 1
if 0 <= int(n[0:2]) <= 99 and 1 <= int(n[2:4]) <= 12:
  ans += 3
if ans == 1:
  print('MMYY')
elif ans == 3:
  print('YYMM')
elif ans == 4:
  print('AMBIGUOUS')
else:
  print('NA')