#include<algorithm>
#include<iostream>
#include<iomanip>
#include<string>

#define oct2dec( b ) ( \
 ((b & 1 <<  0) >>  0) + ((b & 1 <<  3) >>  2) + ((b & 1 <<  6) >>  4) + \
 ((b & 1 <<  9) >>  6) + ((b & 1 << 12) >>  8) + ((b & 1 << 15) >> 10) + \
 ((b & 1 << 18) >> 12) + ((b & 1 << 21) >> 14))

#define B( x ) oct2dec( 0 ## x )

const int en[10] = { B( 0111111 ), B( 0000110 ), B( 1011011 ), B( 1001111 ), B( 1100110 ), 
					B( 1101101 ), B( 1111101 ), B( 0100111 ), B( 1111111 ), B( 1101111 ) };

void showBin( int x )
{
	std::string s;

	while( x > 0 )
	{
		s += ( x & 1 ) + '0';
		x >>= 1;
	}

	std::reverse( s.begin(), s.end() );

	std::cout << std::setw( 7 ) << std::setfill( '0' ) << s << std::endl;

	return;
}

int main()
{
	int n;
	while( std::cin >> n, n != -1 )
	{
		int prv = 0;
		for( int i = 0; i != n; ++i )
		{
			int a;
			std::cin >> a;
			showBin( en[a] ^ prv );
			prv = en[a];
		}
	}

	return 0;
}