solve :: Int -> Int -> Int -> Int -> String
solve s1 s2 s3 s4 = case (b1, b2) of
  (True, True)   -> "AMBIGUOUS"
  (True, False)  -> "MMYY"
  (False, True)  -> "YYMM"
  (False, False) -> "NA"
  where isMonth d1 d2 = d1 * 10 + d2 `elem` [1..12]
        b1 = isMonth s1 s2
        b2 = isMonth s3 s4

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