{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readLn >>= putStrLn . concatMap show . ( \x -> if null x then [0] else x ) . dropWhile ( == 0 ) . solve ( reverse $ take 40 bounds ) ( reverse $ take 40 bases )

bounds = bounds' ( 0, 0 ) 1
	where
		bounds' b@( l, r ) w
			| w > 0 = b : bounds' ( l, r + w ) ( w * (-2) )
			| otherwise = b : bounds' ( l + w, r ) ( w * (-2 ) )

bases = 0 : zipWith (*) ( cycle [ 1, -1 ] ) [ 2 ^ k | k <- [ 0 .. ] ]

solve [ _ ] _ _ = []
solve ( cur : nex : rest ) (b:bs) n
	| inside cur n && not ( inside nex n ) = 1 : solve' ( n - b )
	| otherwise = 0 : solve' n
	where
		inside ( l, r ) n = l <= n && n <= r
		solve' = solve ( nex : rest ) bs