s = input()

s1 = int(s[0])*10 + int(s[1])
s2 = int(s[2])*10 + int(s[3])
#print(s1, s2)
if  (s1>12 or s1==0) and (s2>12 or s2==0):
  print('NA')
elif (s1>12 or s1==0) and 1<=s2<=12:
  print('YYMM')
elif (s2>12 or s2==0) and 1<=s1<=12:
  print('MMYY')
elif 1<=s1<=12 and 1<=s2<=12:
  print('AMBIGUOUS') s = input() s input() input s1 = int(s[0])*10 + int(s[1]) s1 int(s[0])*10 + int(s[1]) int(s[0])*10 int(s[0]) int s[0] s 0 10 int(s[1]) int s[1] s 1 s2 = int(s[2])*10 + int(s[3]) s2 int(s[2])*10 + int(s[3]) int(s[2])*10 int(s[2]) int s[2] s 2 10 int(s[3]) int s[3] s 3 if  (s1>12 or s1==0) and (s2>12 or s2==0):
  print('NA')
elif (s1>12 or s1==0) and 1<=s2<=12:
  print('YYMM')
elif (s2>12 or s2==0) and 1<=s1<=12:
  print('MMYY')
elif 1<=s1<=12 and 1<=s2<=12:
  print('AMBIGUOUS') (s1>12 or s1==0) and (s2>12 or s2==0) s1>12 or s1==0 s1>12 s1 12 s1==0 s1 0 s2>12 or s2==0 s2>12 s2 12 s2==0 s2 0 print('NA') print 'NA' elif (s1>12 or s1==0) and 1<=s2<=12:
  print('YYMM') (s1>12 or s1==0) and 1<=s2<=12 s1>12 or s1==0 s1>12 s1 12 s1==0 s1 0 1<=s2<=12 1<=s2 1 s2 12 print('YYMM') print 'YYMM' elif (s2>12 or s2==0) and 1<=s1<=12:
  print('MMYY') (s2>12 or s2==0) and 1<=s1<=12 s2>12 or s2==0 s2>12 s2 12 s2==0 s2 0 1<=s1<=12 1<=s1 1 s1 12 print('MMYY') print 'MMYY' elif 1<=s1<=12 and 1<=s2<=12:
  print('AMBIGUOUS') 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' s1 = int(s[0])*10 + int(s[1]) int(s[0])*10 + int(s[1]) s1 s = input() input() s s2 = int(s[2])*10 + int(s[3]) int(s[2])*10 + int(s[3]) s2
s = input()

s1 = int(s[0])*10 + int(s[1])
s2 = int(s[2])*10 + int(s[3])
#print(s1, s2)
if  (s1>12 or s1==0) and (s2>12 or s2==0):
  print('NA')
elif (s1>12 or s1==0) and 1<=s2<=12:
  print('YYMM')
elif (s2>12 or s2==0) and 1<=s1<=12:
  print('MMYY')
elif 1<=s1<=12 and 1<=s2<=12:
  print('AMBIGUOUS')