import Data.List (unfoldr) main :: IO () main = readLn >>= putStrLn . concat . map show . reverse . f where f :: Int -> [Int] f 0 = [0] f n = flip unfoldr n (\x -> if x == 0 then Nothing else Just (x `mod` 7, x `div` 7))