import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >>= putStrLn . solve

solve :: String -> String
solve s
    | 0 < x && x < 13 && 0 < y && y < 13 = "AMBIGUOUS"
    | 0 < x && x < 13 = "MMYY"
    | 0 < y && y < 13 = "YYMM"
    | otherwise = "NA" 
    where
        (a, b) = splitAt 2 s
        x = read a :: Int
        y = read b :: Int

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine