S=input()
s1=S[0:2]
s2=S[2:4]
li=["01","02","03","04","05","06","07","08","09","10","11","12"]

if s1 not in li:
    a=False
else:
    a=True
if s2 not in li:
    b=False
else:
    b=True

if a==b==True:
    print("AMBIGUOUS")
elif a==b==False:
    print("NA")
elif a==True:
    print("MMYY")
else:
    print("YYMM") S=input() S input() input s1=S[0:2] s1 S[0:2] S 0:2 0 2 s2=S[2:4] s2 S[2:4] S 2:4 2 4 li=["01","02","03","04","05","06","07","08","09","10","11","12"] li ["01","02","03","04","05","06","07","08","09","10","11","12"] "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" if s1 not in li:
    a=False
else:
    a=True s1 not in li s1 li a=False a False a=True a True if s2 not in li:
    b=False
else:
    b=True s2 not in li s2 li b=False b False b=True b True if a==b==True:
    print("AMBIGUOUS")
elif a==b==False:
    print("NA")
elif a==True:
    print("MMYY")
else:
    print("YYMM") a==b==True a==b a b True print("AMBIGUOUS") print "AMBIGUOUS" elif a==b==False:
    print("NA") a==b==False a==b a b False print("NA") print "NA" elif a==True:
    print("MMYY") a==True a True print("MMYY") print "MMYY" print("YYMM") print "YYMM" li=["01","02","03","04","05","06","07","08","09","10","11","12"] ["01","02","03","04","05","06","07","08","09","10","11","12"] li a=True True a s2=S[2:4] S[2:4] s2 S=input() input() S s1=S[0:2] S[0:2] s1 b=True True b b=False False b a=False False a
S=input()
s1=S[0:2]
s2=S[2:4]
li=["01","02","03","04","05","06","07","08","09","10","11","12"]

if s1 not in li:
    a=False
else:
    a=True
if s2 not in li:
    b=False
else:
    b=True

if a==b==True:
    print("AMBIGUOUS")
elif a==b==False:
    print("NA")
elif a==True:
    print("MMYY")
else:
    print("YYMM")
