TB = [63, 6, 91, 79, 102, 109, 125, 39, 127, 111]

def to_radix(k, v)
  def rec(k, v)
    return [] if v == 0
    [v % k] + rec(k, v / k)
  end
  rec(k, v).reverse
end

def solve(from, to)
  val = (from == -1 ? TB[to] : (TB[from] ^ TB[to])) + 128
  to_radix(2, val).map(&:to_s)[1..-1].join
end

loop do
  from = -1
  n = gets.to_i
  break if n == -1
  n.times do
    to = gets.to_i
    puts solve(from, to)
    from = to
  end  
end