import Data.Char isNum [] = True isNum (a:as) = if (isDigit a) then (isNum as) else False leadingZero [a] = True leadingZero (a:as) = (a == '0') && ((head as) == '0') judge a = ((isNum a) && ((read a) <= 12345)) && (not (leadingZero a)) f a b = if j == True then "OK" else "NG" where ja = judge a jb = judge b j = (ja == True) && (jb == True) main = do a <- getLine b <- getLine putStrLn $ f a b