#include <iostream>
using namespace std;

int main() {
    const char* numberSegments[] = {
        "0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111",
    };
    while (true) {
        int n;
        cin >> n;
        if (n == -1) {
            break;
        }
        char number[] = "0000000";
        for (int i = 0; i < n; i++) {
            int a;
            cin >> a;
            char output[9] = {};
            for (int j = 0; j < (int) (sizeof number / sizeof *number) - 1; j++) {
                if (number[j] == numberSegments[a][j]) {
                    output[j] = '0';
                } else {
                    number[j] = numberSegments[a][j];
                    output[j] = '1';
                }
            }
            cout << output << endl;
        }
    }
}