#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
string dectobin(int n){
	string bin;
	while(n){
		bin+='0'+(n%2);
		n/=2;
	}
	reverse(bin.begin(),bin.end());
	return bin;
}

int main() {
	int d,n;
	char current;
	char digit[10] = {63,6,91,79,102,109,125,39,127,111};
	
	while(cin>>n,n+1){
		current = 0;
		for(int i=0;i<n;++i){
			cin>>d;
			cout<<setfill('0')<<setw(7)<<dectobin((int)(current^digit[d]))<<endl;
			current = digit[d];
		}
	}
	return 0;
}