solve :: Bool -> Bool -> String
solve s1 s2 = case (s1, s2) of
  (True, True)   -> "AMBIGUOUS"
  (True, False)  -> "MMYY"
  (False, True)  -> "YYMM"
  (False, False) -> "NA"

main :: IO ()
main = do
  [s1, s2, s3, s4] <- map (read . (:[])) <$> getLine
  putStrLn $ solve (s1 * 10 + s2 <= 12) (s3 * 10 + s4 <= 12)