import Control.Monad


main :: IO ()
main = do
  n <- readLn
  if n == -1
    then return ()
    else do
      ls <- replicateM n readLn
      let ans = solve ls
      mapM_ putStrLn ans
      main


solve :: [Int] -> [String]
solve ls = update ls "0000000" []
  where
    update :: [Int] -> String -> [String] -> [String]
    update [] _ save = save
    update (x:xs) now save = update xs now' (save ++ [differ now' now])
      where
        now' = toDigit x
          where
            toDigit :: Int -> String
            toDigit n = findD n digit
              where
                digit = [(0,"0111111"),(1,"0000110"),(2,"1011011"),(3,"1001111"),(4,"1100110"),
                         (5,"1101101"),(6,"1111101"),(7,"0100111"),(8,"1111111"),(9,"1101111")]
                findD :: Int -> [(Int,String)] -> String
                findD n ((a,b):r)
                  | n == a = b
                  | otherwise = findD n r
                  
        differ :: String -> String -> String
        differ [] _ = []
        differ (x:xs) (y:ys)
          | x == y = '0':(differ xs ys)
          | otherwise = '1':(differ xs ys)