-- yukicoder My Practice -- author: Leonardone @ NEETSDKASU import Control.Applicative import System.IO import Data.List import Data.Char main = g 10 [] $ replicate 10 '0' where g b ys (x:xs) = 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 10 (x:ys) xs | r < b && b < 10 = g 10 (d:ys) xs | otherwise = g r ys (i:xs)