#include<iostream>
#include<cmath>

char **s;
int m,n,o,set[10] = {63,6,91,79,102,109,125,39,127,111};

void IntToBinary(int a, char *s){
	int b = a;
	for(int i=6; i>=0; i--){
		if(b >= pow(2.0,i)){
			b -= pow(2.0,i);
			s[6-i] = '1';
		}else
			s[6-i] = '0';
	}
	s[7] = '\0';
}

int main(){
	while(true){
		std::cin >> n;
		if(n == -1)
			return 0;
		s = new char*[n];
		for(int i=0; i<n; i++)
			s[i] = new char[8];
		std::cin >> m;
		IntToBinary(set[m], s[0]);
		for(int i=1; i<n; i++){
			std::cin >> o;
			IntToBinary(set[m]^set[o], s[i]);
			m = o;
		}
		for(int i=0; i<n; i++){
			std::cout << s[i] << std::endl;
			delete[] s[i];
		}
		delete[] s;
	}
}