import qualified Data.Map as Map



f::Int->Int->String->[(Int,String)]
f (-1) n str=[(n,str)]
f m n str=(f (m-2) (n+((-2)^m)) (str++"10"))++(f (m-2) n (str++"00"))

f2::Int->Int->String->Map.Map Int String->String
f2 34 _ _ _=""
f2 m n str ms
     |Map.member n ms=let t1=(Map.lookup n ms)
                          (Just t2)=t1
                      in t2++" "++str
     |otherwise = (f2 (m+2) n ("00"++str) ms)++(f2 (m+2) (n-(2^m)) ("01"++str) ms)

f3::String->String->String
f3 "" ys=ys
f3 xs ""=xs
f3 (_:xs) ('1':ys)='1':f3 xs ys
f3 ('1':xs) (_:ys)='1':f3 xs ys
f3 (_:xs) (_:ys)='0':f3 xs ys

main = do
       a<-getLine
       let b=read a::Int
           ms=(Map.fromList (f 33 0 ""))
           (c:d:_)=(map reverse) $ words $ f2 0 b "" ms
       if b==0 then putStrLn "0" 
       else let (_,ans)=span (=='0') (reverse (f3 c d)) in putStrLn ans