s = input()
s1, s2 = s[:2],s[2:]
if s1>'12' and s2>'12':
    print('NA')
elif s1<='12' and s2<='12':
    if s1 == '00' and s2!='00':
        print('YYMM')
    elif s2 == '00' and s1!='00':
        print('MMYY')
    elif s1 =='00' and s2 =='00':
        print('NA')
    else :
        print('AMBIGUOUS')
elif s1<='12' and s2>'12':
    print('NA' if s1 == '00' else 'MMYY')   
elif s2<='12' and s1>'12':
    print('NA' if s2 == '00' else 'YYMM')
else:
    print('NA') s = input() s input() input s1, s2 = s[:2],s[2:] s1 s[:2] s :2 2 s2 s[2:] s 2: 2 if s1>'12' and s2>'12':
    print('NA')
elif s1<='12' and s2<='12':
    if s1 == '00' and s2!='00':
        print('YYMM')
    elif s2 == '00' and s1!='00':
        print('MMYY')
    elif s1 =='00' and s2 =='00':
        print('NA')
    else :
        print('AMBIGUOUS')
elif s1<='12' and s2>'12':
    print('NA' if s1 == '00' else 'MMYY')   
elif s2<='12' and s1>'12':
    print('NA' if s2 == '00' else 'YYMM')
else:
    print('NA') s1>'12' and s2>'12' s1>'12' s1 '12' s2>'12' s2 '12' print('NA') print 'NA' elif s1<='12' and s2<='12':
    if s1 == '00' and s2!='00':
        print('YYMM')
    elif s2 == '00' and s1!='00':
        print('MMYY')
    elif s1 =='00' and s2 =='00':
        print('NA')
    else :
        print('AMBIGUOUS') s1<='12' and s2<='12' s1<='12' s1 '12' s2<='12' s2 '12' if s1 == '00' and s2!='00':
        print('YYMM')
    elif s2 == '00' and s1!='00':
        print('MMYY')
    elif s1 =='00' and s2 =='00':
        print('NA')
    else :
        print('AMBIGUOUS') s1 == '00' and s2!='00' s1 == '00' s1 '00' s2!='00' s2 '00' print('YYMM') print 'YYMM' elif s2 == '00' and s1!='00':
        print('MMYY')
     s2 == '00' and s1!='00' s2 == '00' s2 '00' s1!='00' s1 '00' print('MMYY') print 'MMYY' elif s1 =='00' and s2 =='00':
        print('NA')
     s1 =='00' and s2 =='00' s1 =='00' s1 '00' s2 =='00' s2 '00' print('NA') print 'NA' print('AMBIGUOUS') print 'AMBIGUOUS' elif s1<='12' and s2>'12':
    print('NA' if s1 == '00' else 'MMYY')    s1<='12' and s2>'12' s1<='12' s1 '12' s2>'12' s2 '12' print('NA' if s1 == '00' else 'MMYY') print 'NA' if s1 == '00' else 'MMYY' s1 == '00' s1 '00' 'NA' 'MMYY' elif s2<='12' and s1>'12':
    print('NA' if s2 == '00' else 'YYMM') s2<='12' and s1>'12' s2<='12' s2 '12' s1>'12' s1 '12' print('NA' if s2 == '00' else 'YYMM') print 'NA' if s2 == '00' else 'YYMM' s2 == '00' s2 '00' 'NA' 'YYMM' print('NA') print 'NA' s1, s2 = s[:2],s[2:] s[:2] s1 s = input() input() s s2 = s[:2],s[2:] s[2:] s2
s = input()
s1, s2 = s[:2],s[2:]
if s1>'12' and s2>'12':
    print('NA')
elif s1<='12' and s2<='12':
    if s1 == '00' and s2!='00':
        print('YYMM')
    elif s2 == '00' and s1!='00':
        print('MMYY')
    elif s1 =='00' and s2 =='00':
        print('NA')
    else :
        print('AMBIGUOUS')
elif s1<='12' and s2>'12':
    print('NA' if s1 == '00' else 'MMYY')   
elif s2<='12' and s1>'12':
    print('NA' if s2 == '00' else 'YYMM')
else:
    print('NA')