s=input()

mae=int(s[:2])
ushiro=int(s[2:])

if 1<=mae<=12:
    if 1<=ushiro<=12:
        ans="AMBIGUOUS"
    else:
        ans="MMYY"

elif 1<=ushiro<=12:
    ans="YYMM"

else:
    ans="NA"
    
print(ans) s=input() s input() input mae=int(s[:2]) mae int(s[:2]) int s[:2] s :2 2 ushiro=int(s[2:]) ushiro int(s[2:]) int s[2:] s 2: 2 if 1<=mae<=12:
    if 1<=ushiro<=12:
        ans="AMBIGUOUS"
    else:
        ans="MMYY"

elif 1<=ushiro<=12:
    ans="YYMM"

else:
    ans="NA"
     1<=mae<=12 1<=mae 1 mae 12 if 1<=ushiro<=12:
        ans="AMBIGUOUS"
    else:
        ans="MMYY" 1<=ushiro<=12 1<=ushiro 1 ushiro 12 ans="AMBIGUOUS" ans "AMBIGUOUS" ans="MMYY" ans "MMYY" elif 1<=ushiro<=12:
    ans="YYMM" 1<=ushiro<=12 1<=ushiro 1 ushiro 12 ans="YYMM" ans "YYMM" ans="NA" ans "NA" print(ans) print ans ans="AMBIGUOUS" "AMBIGUOUS" ans ans="YYMM" "YYMM" ans mae=int(s[:2]) int(s[:2]) mae ushiro=int(s[2:]) int(s[2:]) ushiro s=input() input() s ans="MMYY" "MMYY" ans ans="NA" "NA" ans
s=input()

mae=int(s[:2])
ushiro=int(s[2:])

if 1<=mae<=12:
    if 1<=ushiro<=12:
        ans="AMBIGUOUS"
    else:
        ans="MMYY"

elif 1<=ushiro<=12:
    ans="YYMM"

else:
    ans="NA"
    
print(ans)