f ('0':_:_) = True f xs | foldr p False xs = True | otherwise = if read xs > 12345 then True else False where p x y = any (==x) moji || y moji = ['a'..'z'] ++ ['A'..'Z'] solve as bs | f as || f bs = "NG" | otherwise = "OK" main = do as <- getLine bs <- getLine putStrLn $ solve as bs