{-# LANGUAGE OverloadedStrings, BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> B.ByteString
solve !a !b | isMonth a && isMonth b       = "AMBIGUOUS"
            | isMonth a && not (isMonth b) = "MMYY"
            | isMonth b && not (isMonth a) = "YYMM"
            | otherwise                    = "NA"
 where
  isYear n = True
  isMonth n = n >= 1 && n <= 12

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  s <- B.getLine
  B.putStrLn $ solve ((\(Just (x, _)) -> x) $ readInt $ B.take 2 s)
                     ((\(Just (x, _)) -> x) $ readInt $ B.drop 2 s)
