s=list(input())
S=[]
for i in range(len(s)):
    S.append(int(s[i]))
if 1<=S[2]*10+S[3] and S[2]*10+S[3]<=12:
    if 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12:
        print('MMYY')
    else:
        print('NA') s=list(input()) s list(input()) list input() input S=[] S [] for i in range(len(s)):
    S.append(int(s[i])) i range(len(s)) range len(s) len s S.append(int(s[i])) S.append S append int(s[i]) int s[i] s i if 1<=S[2]*10+S[3] and S[2]*10+S[3]<=12:
    if 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12:
        print('MMYY')
    else:
        print('NA') 1<=S[2]*10+S[3] and S[2]*10+S[3]<=12 1<=S[2]*10+S[3] 1 S[2]*10+S[3] S[2]*10 S[2] S 2 10 S[3] S 3 S[2]*10+S[3]<=12 S[2]*10+S[3] S[2]*10 S[2] S 2 10 S[3] S 3 12 if 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12:
        print('AMBIGUOUS')
    else:
        print('YYMM') 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12 1<=S[0]*10+S[1] 1 S[0]*10+S[1] S[0]*10 S[0] S 0 10 S[1] S 1 S[0]*10+S[1]<=12 S[0]*10+S[1] S[0]*10 S[0] S 0 10 S[1] S 1 12 print('AMBIGUOUS') print 'AMBIGUOUS' print('YYMM') print 'YYMM' if 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12:
        print('MMYY')
    else:
        print('NA') 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12 1<=S[0]*10+S[1] 1 S[0]*10+S[1] S[0]*10 S[0] S 0 10 S[1] S 1 S[0]*10+S[1]<=12 S[0]*10+S[1] S[0]*10 S[0] S 0 10 S[1] S 1 12 print('MMYY') print 'MMYY' print('NA') print 'NA' S=[] [] S s=list(input()) list(input()) s
s=list(input())
S=[]
for i in range(len(s)):
    S.append(int(s[i]))
if 1<=S[2]*10+S[3] and S[2]*10+S[3]<=12:
    if 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12:
        print('MMYY')
    else:
        print('NA')