solve (s_) 
    | f1 && f2 = "AMBIGUOUS"
    | f1 = "MMYY"
    | f2 = "YYMM"
    | otherwise = "NA"
    where
        s = take 4 s_ 
        check i_ = 0 < i && i < 13 where i = read i_
        f1 = check $ take 2 s
        f2 = check $ drop 2 s

main = interact solve
