-- yukicoder My Practice -- author: Leonardone @ NEETSDKASU import Control.Applicative import System.IO import Data.List import Data.Char main = g ['0' | _ <- [1..10]] [] 10 where g (x:xs) ys b = h =<< m where m = putStrLn str >> hFlush stdout >> read . head . words <$> getLine str = flip (++) (x:xs) $ reverse ys calc o = chr . flip o 1 . ord d = calc (-) x i = calc (+) x h r | r == 10 = pure () | r > b = g xs (x:ys) 10 | r < b && b < 10 = g xs (d:ys) 10 | otherwise = g (i:xs) ys r