s=eval(input());print((['NA','MMYY','YYMM','AMBIGUOUS'][(0<int(s[:2])<13)-(0<int(s[2:])<13)*2]))
s=eval(input());print((['NA','MMYY','YYMM','AMBIGUOUS'][('01'<s<'13')-('00'<s[2:]<'13')*2]))
s = eval(input())
print(
    (
        ["NA", "MMYY", "YYMM", "AMBIGUOUS"][
            (0 < int(s[:2]) < 13) - (0 < int(s[2:]) < 13) * 2
        ]
    )
)

s = eval(input())
print(
    (["NA", "MMYY", "YYMM", "AMBIGUOUS"][("01" < s < "13") - ("00" < s[2:] < "13") * 2])
)

-    ( -        ["NA", "MMYY", "YYMM", "AMBIGUOUS"][ -            (0 < int(s[:2]) < 13) - (0 < int(s[2:]) < 13) * 2 -        ] -    ) +    (["NA", "MMYY", "YYMM", "AMBIGUOUS"][("01" < s < "13") - ("00" < s[2:] < "13") * 2])