#include<iostream>
#include<string>
#include<bitset>
using namespace std;

int nikara (const string &sig);
void tenkara ( int );

int main () {
	string sig[10] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
	string before,hoge;
	int n,num;
	int var = 0x0001;
	int bvar,piyo;
	
	while ( cin >> n, n != -1 ){
		bvar = 0;
		for ( int i = 0; i < n; i++ ) {
			cin >> num;
			hoge = sig[num];
			
			var = nikara ( hoge );
			piyo = var ^ bvar;
			tenkara ( piyo );
			
			bvar = var;
		}
	}
}

int nikara (const string &sig) {
	int out = 0;
	for (int i = 0, size = sig.size(); i < size ; ++i ) {
		out *= 2;
		out += ((int)sig[i] == 49) ? 1 : 0;
	}
	return out;
}

void tenkara (int hoge) {
	string sig;
	for ( int i = 0; i < 7; i++ ) {
		sig[i] = hoge % 2 + '0';
		hoge = hoge / 2;
	}
	
	for ( int i = 6; i >= 0; i-- ) {
		cout << sig[i];
	}
	cout << endl;
}