# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0228

"""
import sys
from sys import stdin
input = stdin.readline


LED_pattern = [
    ##-gfedcba
    0b0111111,                #  0
    0b0000110,                #  1
    0b1011011,                #  2
    0b1001111,                #  3
    0b1100110,                #  4
    0b1101101,                #  5
    0b1111101,                #  6
    0b0100111,                #  7
    0b1111111,                #  8
    0b1101111,                #  9
    0b0000000                 #  all OFF
]


def solve(cp, np):
    a = LED_pattern[cp]
    b = LED_pattern[np]
    return bin(a ^ b)[2:].zfill(7)


def main(args):
    while True:
        n = int(input())
        if n == -1:
            break
        cp = 10                 #  all OFF
        for _ in range(n):
            d = int(input())
            ans = solve(cp, d)
            cp = d
            print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])