s = list(map(int, input()))
l = [0]*2
l[0] = s[0]*10 + s[1]
l[1] = s[2]*10 + s[3]

F = False
L = False

if 0 < l[0] <= 12:
  F = True
if 0 < l[1] <= 12:
  L = True

if F == True and L == True:
  print('AMBIGUOUS')

elif F == True:
  print('MMYY')

elif L == True:
  print('YYMM')

else:
  print('NA') s = list(map(int, input())) s list(map(int, input())) list map(int, input()) map int input() input l = [0]*2 l [0]*2 [0] 0 2 l[0] = s[0]*10 + s[1] l[0] l 0 s[0]*10 + s[1] s[0]*10 s[0] s 0 10 s[1] s 1 l[1] = s[2]*10 + s[3] l[1] l 1 s[2]*10 + s[3] s[2]*10 s[2] s 2 10 s[3] s 3 F = False F False L = False L False if 0 < l[0] <= 12:
  F = True 0 < l[0] <= 12 0 < l[0] 0 l[0] l 0 12 F = True F True if 0 < l[1] <= 12:
  L = True 0 < l[1] <= 12 0 < l[1] 0 l[1] l 1 12 L = True L True if F == True and L == True:
  print('AMBIGUOUS')

elif F == True:
  print('MMYY')

elif L == True:
  print('YYMM')

else:
  print('NA') F == True and L == True F == True F True L == True L True print('AMBIGUOUS') print 'AMBIGUOUS' elif F == True:
  print('MMYY') F == True F True print('MMYY') print 'MMYY' elif L == True:
  print('YYMM') L == True L True print('YYMM') print 'YYMM' print('NA') print 'NA' F = False False F l = [0]*2 [0]*2 l L = False False L L = True True L s = list(map(int, input())) list(map(int, input())) s F = True True F
s = list(map(int, input()))
l = [0]*2
l[0] = s[0]*10 + s[1]
l[1] = s[2]*10 + s[3]

F = False
L = False

if 0 < l[0] <= 12:
  F = True
if 0 < l[1] <= 12:
  L = True

if F == True and L == True:
  print('AMBIGUOUS')

elif F == True:
  print('MMYY')

elif L == True:
  print('YYMM')

else:
  print('NA')