-- yukicoder My Practice -- author: Leonardone @ NEETSDKASU import Control.Applicative import System.IO import Data.List import Data.Char main = g ['0' | _ <- [1..10]] [] 10 f s = putStrLn s >> hFlush stdout >> read . head . words <$> getLine g (x:xs) ys b = do r <- f $ (x:xs) ++ ys case r of 10 -> return () r | r > b -> g xs (x:ys) 10 r | r < b -> g xs ((dec x):ys) 10 _ -> g ((inc x):xs) ys r where calc c o = chr $ flip o 1 $ ord $ c dec c = calc c (-) inc c = calc c (+)