S = str(input())
F = S[:2]
L = S[2:]
if F == "00" or int(F)>12:
    if L == "00" or int(L) > 12:
        ans = "NA"
    else:
        ans = "YYMM"
elif int(F) <= 12:
    if int(L) >= 1 and int(L) <=12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"    
print(ans) S = str(input()) S str(input()) str input() input F = S[:2] F S[:2] S :2 2 L = S[2:] L S[2:] S 2: 2 if F == "00" or int(F)>12:
    if L == "00" or int(L) > 12:
        ans = "NA"
    else:
        ans = "YYMM"
elif int(F) <= 12:
    if int(L) >= 1 and int(L) <=12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"     F == "00" or int(F)>12 F == "00" F "00" int(F)>12 int(F) int F 12 if L == "00" or int(L) > 12:
        ans = "NA"
    else:
        ans = "YYMM" L == "00" or int(L) > 12 L == "00" L "00" int(L) > 12 int(L) int L 12 ans = "NA" ans "NA" ans = "YYMM" ans "YYMM" elif int(F) <= 12:
    if int(L) >= 1 and int(L) <=12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"     int(F) <= 12 int(F) int F 12 if int(L) >= 1 and int(L) <=12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"     int(L) >= 1 and int(L) <=12 int(L) >= 1 int(L) int L 1 int(L) <=12 int(L) int L 12 ans = "AMBIGUOUS" ans "AMBIGUOUS" ans = "MMYY" ans "MMYY" print(ans) print ans F = S[:2] S[:2] F L = S[2:] S[2:] L ans = "NA" "NA" ans ans = "YYMM" "YYMM" ans ans = "MMYY" "MMYY" ans ans = "AMBIGUOUS" "AMBIGUOUS" ans S = str(input()) str(input()) S
S = str(input())
F = S[:2]
L = S[2:]
if F == "00" or int(F)>12:
    if L == "00" or int(L) > 12:
        ans = "NA"
    else:
        ans = "YYMM"
elif int(F) <= 12:
    if int(L) >= 1 and int(L) <=12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"    
print(ans)