#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

string to_bit(char n) {
    string s;
    for(int i = 0; i < 7; i++) {
        s.push_back((n & (1 << i)) ? '1' : '0');
    }
    return s;
}

int main() {
    for(int N; cin >> N, N != -1; ) {
        char state = 0;
        char numbers[] = {
            0b01111110,
            0b00110000,
            0b01101101,
            0b01111001,
            0b00110011,
            0b01011011,
            0b01011111,
            0b01110010,
            0b01111111,
            0b01111011
        };
        while(N--) {
            int T; cin >> T;
            string ans = "NA";
            for(char i = 0; i < (1 << 7); i++) {
                if((state ^ i) == numbers[T]) {
                    ans = to_bit(i);
                    state ^= i;
                    break;
                }
            }
            cout << ans << endl;
        }

    }
}