# Aizu Problem 0228: Seven Segments

import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


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

while True:
    n = int(input())
    if n == -1:
        break
    e = 0
    for i in range(n):
        a = digits[int(input())]
        print("{:07b}".format(a^e))
        e = a