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

string seg[]={"1111110","0110000","1101101","1111001","0110011","1011011","1011111","1110010","1111111","1111011"};

int str2int(string str)
{
	int ret=0,dig=1;
	for(int i=0; i<7; i++)
	{
		ret+=(str[i]-'0')*dig;
		dig*=2;
	}

	return ret;
}

void output(int a)
{
	int dig=(1<<6);
	string ret;
	for(int i=0; i<7; i++)
	{
		ret+=(a/dig + '0');
		a%=dig;
		dig/=2;
	}

	cout << ret  << endl;
}

int main()
{
	int N;
	while(cin >> N, N!=-1)
	{
		int stat=0;
		while(N--)
		{
			int t;
			cin >> t;
			output(stat^str2int(seg[t]));
			stat = str2int(seg[t]);
		}

	}
}