import Data.Char main = getContents >>= putStrLn . show' . all ok . words where show' p = if p then "OK" else "NG" ok s | s == "0" = True | notElem (head s) ['1'..'9'] = False | otherwise = let (n,xs) = head (reads s) in 0<=n && n<=12345 && null xs