s = input()

s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
#print(s1, s2)
L=[]

for i in range(1, 13):
    L.append(i)


if s1 not in L and s2 not in L:
    print('NA')
elif s1 in L and s2 not in L:
    print('MMYY')
elif s1 not in L and s2 in L:
    print('YYMM')
else:
    print('AMBIGUOUS') s = input() s input() input s1 = int(s[0]+s[1]) s1 int(s[0]+s[1]) int s[0]+s[1] s[0] s 0 s[1] s 1 s2 = int(s[2]+s[3]) s2 int(s[2]+s[3]) int s[2]+s[3] s[2] s 2 s[3] s 3 L=[] L [] for i in range(1, 13):
    L.append(i) i range(1, 13) range 1 13 L.append(i) L.append L append i if s1 not in L and s2 not in L:
    print('NA')
elif s1 in L and s2 not in L:
    print('MMYY')
elif s1 not in L and s2 in L:
    print('YYMM')
else:
    print('AMBIGUOUS') s1 not in L and s2 not in L s1 not in L s1 L s2 not in L s2 L print('NA') print 'NA' elif s1 in L and s2 not in L:
    print('MMYY') s1 in L and s2 not in L s1 in L s1 L s2 not in L s2 L print('MMYY') print 'MMYY' elif s1 not in L and s2 in L:
    print('YYMM') s1 not in L and s2 in L s1 not in L s1 L s2 in L s2 L print('YYMM') print 'YYMM' print('AMBIGUOUS') print 'AMBIGUOUS' s2 = int(s[2]+s[3]) int(s[2]+s[3]) s2 s = input() input() s L=[] [] L s1 = int(s[0]+s[1]) int(s[0]+s[1]) s1
s = input()

s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
#print(s1, s2)
L=[]

for i in range(1, 13):
    L.append(i)


if s1 not in L and s2 not in L:
    print('NA')
elif s1 in L and s2 not in L:
    print('MMYY')
elif s1 not in L and s2 in L:
    print('YYMM')
else:
    print('AMBIGUOUS')
