solver::String->String
solver (a:b:c:d:_) = let fo = read (a:b:[]) in
                     let la = read (c:d:[]) in
                     if fo == 0 && la == 0 then "NA\n" else
                     case (fo < 13 && fo > 0, la < 13 && la > 0) of
                       (False,False) -> "NA\n"
                       (False,True ) -> "YYMM\n"
                       (True ,False) -> "MMYY\n"
                       (True ,True ) -> "AMBIGUOUS\n"

main::IO()
main=putStr.solver=<<getLine