import Data.Char
main = do
  [a,b,c,d] <- map digitToInt <$> getLine
  putStrLn $ f (a*10+b) (c*10+d)

f x y
  | isM x && isM y       = "AMBIGUOUS"
  | isM x && not (isM y) = "MMYY"
  | not (isM x) && isM y = "YYMM"
  | otherwise            = "NA"
  where
    isM n = 1 <= n && n <= 12