s=str(input())
a="Y"
b="Y"
if 0<int(s[0:2])<13:
    a="MY"
if 0<int(s[2:5])<13:
    b="MY"

if a==b=="Y":
    ans="NA"
elif a=="Y" and b=="MY":
    ans="YYMM"
elif a=="MY" and b=="Y":
    ans="MMYY"
else:
    ans="AMBIGUOUS"
print(ans) s=str(input()) s str(input()) str input() input a="Y" a "Y" b="Y" b "Y" if 0<int(s[0:2])<13:
    a="MY" 0<int(s[0:2])<13 0<int(s[0:2]) 0 int(s[0:2]) int s[0:2] s 0:2 0 2 13 a="MY" a "MY" if 0<int(s[2:5])<13:
    b="MY" 0<int(s[2:5])<13 0<int(s[2:5]) 0 int(s[2:5]) int s[2:5] s 2:5 2 5 13 b="MY" b "MY" if a==b=="Y":
    ans="NA"
elif a=="Y" and b=="MY":
    ans="YYMM"
elif a=="MY" and b=="Y":
    ans="MMYY"
else:
    ans="AMBIGUOUS" a==b=="Y" a==b a b "Y" ans="NA" ans "NA" elif a=="Y" and b=="MY":
    ans="YYMM" a=="Y" and b=="MY" a=="Y" a "Y" b=="MY" b "MY" ans="YYMM" ans "YYMM" elif a=="MY" and b=="Y":
    ans="MMYY" a=="MY" and b=="Y" a=="MY" a "MY" b=="Y" b "Y" ans="MMYY" ans "MMYY" ans="AMBIGUOUS" ans "AMBIGUOUS" print(ans) print ans a="Y" "Y" a s=str(input()) str(input()) s ans="MMYY" "MMYY" ans b="Y" "Y" b a="MY" "MY" a b="MY" "MY" b ans="AMBIGUOUS" "AMBIGUOUS" ans ans="YYMM" "YYMM" ans ans="NA" "NA" ans
s=str(input())
a="Y"
b="Y"
if 0<int(s[0:2])<13:
    a="MY"
if 0<int(s[2:5])<13:
    b="MY"

if a==b=="Y":
    ans="NA"
elif a=="Y" and b=="MY":
    ans="YYMM"
elif a=="MY" and b=="Y":
    ans="MMYY"
else:
    ans="AMBIGUOUS"
print(ans)