S=input()
l=len(S)
Y=0
M=0
for i in range(l):
    if i==3:
        if int(S[i-1])==0 and 1<=int(S[i])<=9:
            Y=1
        elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            Y=1
for i in range(l):
    if i==1:
        if int(S[i-1])==0 and 1<=int(S[i])<=9:
            M=1
        elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            M=1
if Y==1 and M==1:
    print('AMBIGUOUS')
elif Y==1 and M==0:
    print('YYMM')
elif Y==0 and M==1:
    print('MMYY')
elif Y==0 and M==0:
    print('NA') S=input() S input() input l=len(S) l len(S) len S Y=0 Y 0 M=0 M 0 for i in range(l):
    if i==3:
        if int(S[i-1])==0 and 1<=int(S[i])<=9:
            Y=1
        elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            Y=1 i range(l) range l if i==3:
        if int(S[i-1])==0 and 1<=int(S[i])<=9:
            Y=1
        elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            Y=1 i==3 i 3 if int(S[i-1])==0 and 1<=int(S[i])<=9:
            Y=1
        elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            Y=1 int(S[i-1])==0 and 1<=int(S[i])<=9 int(S[i-1])==0 int(S[i-1]) int S[i-1] S i-1 i 1 0 1<=int(S[i])<=9 1<=int(S[i]) 1 int(S[i]) int S[i] S i 9 Y=1 Y 1 elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            Y=1 int(S[i-1])==1 and 0<=int(S[i])<=2 int(S[i-1])==1 int(S[i-1]) int S[i-1] S i-1 i 1 1 0<=int(S[i])<=2 0<=int(S[i]) 0 int(S[i]) int S[i] S i 2 Y=1 Y 1 for i in range(l):
    if i==1:
        if int(S[i-1])==0 and 1<=int(S[i])<=9:
            M=1
        elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            M=1 i range(l) range l if i==1:
        if int(S[i-1])==0 and 1<=int(S[i])<=9:
            M=1
        elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            M=1 i==1 i 1 if int(S[i-1])==0 and 1<=int(S[i])<=9:
            M=1
        elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            M=1 int(S[i-1])==0 and 1<=int(S[i])<=9 int(S[i-1])==0 int(S[i-1]) int S[i-1] S i-1 i 1 0 1<=int(S[i])<=9 1<=int(S[i]) 1 int(S[i]) int S[i] S i 9 M=1 M 1 elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            M=1 int(S[i-1])==1 and 0<=int(S[i])<=2 int(S[i-1])==1 int(S[i-1]) int S[i-1] S i-1 i 1 1 0<=int(S[i])<=2 0<=int(S[i]) 0 int(S[i]) int S[i] S i 2 M=1 M 1 if Y==1 and M==1:
    print('AMBIGUOUS')
elif Y==1 and M==0:
    print('YYMM')
elif Y==0 and M==1:
    print('MMYY')
elif Y==0 and M==0:
    print('NA') Y==1 and M==1 Y==1 Y 1 M==1 M 1 print('AMBIGUOUS') print 'AMBIGUOUS' elif Y==1 and M==0:
    print('YYMM') Y==1 and M==0 Y==1 Y 1 M==0 M 0 print('YYMM') print 'YYMM' elif Y==0 and M==1:
    print('MMYY') Y==0 and M==1 Y==0 Y 0 M==1 M 1 print('MMYY') print 'MMYY' elif Y==0 and M==0:
    print('NA') Y==0 and M==0 Y==0 Y 0 M==0 M 0 print('NA') print 'NA' l=len(S) len(S) l Y=1 1 Y M=1 1 M S=input() input() S Y=1 1 Y Y=0 0 Y M=1 1 M M=0 0 M
S=input()
l=len(S)
Y=0
M=0
for i in range(l):
    if i==3:
        if int(S[i-1])==0 and 1<=int(S[i])<=9:
            Y=1
        elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            Y=1
for i in range(l):
    if i==1:
        if int(S[i-1])==0 and 1<=int(S[i])<=9:
            M=1
        elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            M=1
if Y==1 and M==1:
    print('AMBIGUOUS')
elif Y==1 and M==0:
    print('YYMM')
elif Y==0 and M==1:
    print('MMYY')
elif Y==0 and M==0:
    print('NA')