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
    | xx > 12 && yy >12 = NA
    | xx > 12 && yy > 0 && yy <=12 = YYMM
    | yy > 12 && xx > 0 && xx <=12 = MMYY
    | xx <=12 && xx > 0 && yy <=12 && yy > 0 = AMBIGUOUS
    | xx == 0 && yy > 12 = NA
    | yy == 0 && xx > 12 = NA
    | xx == 0 && yy == 0 = NA
    | xx == 12 && yy == 0 = MMYY
    | xx == 0 && yy == 12 = YYMM
    | otherwise = NA