import Data.Char (isDigit) main :: IO () main = do a <- getLine b <- getLine putStrLn $ if check a && check b then "OK" else "NG" check :: String -> Bool check s = (s == "0" || head s /= '0') && all isDigit s && ns <= 12345 where allDig = all isDigit s ns = if allDig then read s else maxBound :: Int