import Control.Applicative ((<$>)) import Control.Monad (unless) import System.IO (hFlush, stdout) import Text.Printf main :: IO () main = do printf "%010d\n" (0::Int) hFlush stdout [s,rslt] <- words <$> getLine unless (rslt == "unlocked") $ solve (read s) 0 1 solve :: Int -> Int -> Int -> IO () solve mtc ecn d = do let nn = ecn + d printf "%010d\n" nn hFlush stdout [s,rslt] <- words <$> getLine unless (rslt == "unlocked") $ do let nc = read s :: Int if nc > mtc then do solve nc nn (d * 10) else if nc < mtc then do solve mtc ecn (d * 10) else do solve mtc nn d