data DataType = YYMM | MMYY | AMBIGUOUS | NA deriving (Eq,Show)

main = do
	str <- getLine
	putStrLn.show $ answer (read $ take 2 str) (read $ drop 2 str)

answer :: Int -> Int -> DataType
answer xx yy
	| yy > 0 && yy <=12 = YYMM
	| xx > 0 && xx <=12 = MMYY
	| xx <=12 && xx > 0 && yy <=12 && yy > 0 = AMBIGUOUS
	| otherwise = NA