main :: IO ()
main = do
  s <- getLine
  case solve s of
    YYMM      -> putStrLn "YYMM"
    MMYY      -> putStrLn "MMYY"
    Ambiguous -> putStrLn "AMBIGUOUS"
    NA        -> putStrLn "NA"

solve :: String -> Format
solve s = solve' yymm mmyy where
  a = read $ take 2 s
  b = read $ drop 2 s
  yymm = isYYMM a b
  mmyy = isMMYY a b

solve' :: Bool -> Bool -> Format
solve' False False = NA
solve' False True  = MMYY
solve' True False  = YYMM
solve' True True   = Ambiguous

isYYMM :: Int -> Int -> Bool
isYYMM _ b = isMM b

isMMYY :: Int -> Int -> Bool
isMMYY a _ = isMM a

isMM :: Int -> Bool
isMM a = 1 <= a && a <= 12

data Format = YYMM | MMYY | Ambiguous | NA
