s  = input()
l = int(s[0]) * 10 + int(s[1])
r = int(s[2]) * 10 + int(s[3])

res = "NA"
if l == 0:
    if 1 <= r <= 12:
        res = "YYMM"
    else:
        res = "NA"
elif 1 <= l <= 12:
    if 1 <= r <= 12:
        res ="AMBIGUOUS"
    else:
        res = "MMYY"
else:
    if 1 <= r <= 12:
        res = "YYMM"
    else:
        res = "NA"

print(res) s  = input() s input() input l = int(s[0]) * 10 + int(s[1]) l int(s[0]) * 10 + int(s[1]) int(s[0]) * 10 int(s[0]) int s[0] s 0 10 int(s[1]) int s[1] s 1 r = int(s[2]) * 10 + int(s[3]) r int(s[2]) * 10 + int(s[3]) int(s[2]) * 10 int(s[2]) int s[2] s 2 10 int(s[3]) int s[3] s 3 res = "NA" res "NA" if l == 0:
    if 1 <= r <= 12:
        res = "YYMM"
    else:
        res = "NA"
elif 1 <= l <= 12:
    if 1 <= r <= 12:
        res ="AMBIGUOUS"
    else:
        res = "MMYY"
else:
    if 1 <= r <= 12:
        res = "YYMM"
    else:
        res = "NA" l == 0 l 0 if 1 <= r <= 12:
        res = "YYMM"
    else:
        res = "NA" 1 <= r <= 12 1 <= r 1 r 12 res = "YYMM" res "YYMM" res = "NA" res "NA" elif 1 <= l <= 12:
    if 1 <= r <= 12:
        res ="AMBIGUOUS"
    else:
        res = "MMYY" 1 <= l <= 12 1 <= l 1 l 12 if 1 <= r <= 12:
        res ="AMBIGUOUS"
    else:
        res = "MMYY" 1 <= r <= 12 1 <= r 1 r 12 res ="AMBIGUOUS" res "AMBIGUOUS" res = "MMYY" res "MMYY" if 1 <= r <= 12:
        res = "YYMM"
    else:
        res = "NA" 1 <= r <= 12 1 <= r 1 r 12 res = "YYMM" res "YYMM" res = "NA" res "NA" print(res) print res l = int(s[0]) * 10 + int(s[1]) int(s[0]) * 10 + int(s[1]) l res = "YYMM" "YYMM" res s  = input() input() s res = "NA" "NA" res res ="AMBIGUOUS" "AMBIGUOUS" res res = "NA" "NA" res res = "YYMM" "YYMM" res res = "NA" "NA" res res = "MMYY" "MMYY" res r = int(s[2]) * 10 + int(s[3]) int(s[2]) * 10 + int(s[3]) r
s  = input()
l = int(s[0]) * 10 + int(s[1])
r = int(s[2]) * 10 + int(s[3])

res = "NA"
if l == 0:
    if 1 <= r <= 12:
        res = "YYMM"
    else:
        res = "NA"
elif 1 <= l <= 12:
    if 1 <= r <= 12:
        res ="AMBIGUOUS"
    else:
        res = "MMYY"
else:
    if 1 <= r <= 12:
        res = "YYMM"
    else:
        res = "NA"

print(res)
