#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int bit[11][7] = {
	{1,1,1,1,1,1,0},
	{0,1,1,0,0,0,0},
	{1,1,0,1,1,0,1},
	{1,1,1,1,0,0,1},
	{0,1,1,0,0,1,1},
	{1,0,1,1,0,1,1},
	{1,0,1,1,1,1,1},
	{1,1,1,0,0,1,0},
	{1,1,1,1,1,1,1},
	{1,1,1,1,0,1,1},
	{0,0,0,0,0,0,0},
};

int main() {
	int n;
	
	while (cin >> n) {
		if (n == -1) break;
		
		int p = 10;
		
		for_(i,0,n) {
			int c;
			cin >> c;
			
			for_(i,0,7) cout << (bit[c][7 - i - 1] == bit[p][7 - i - 1] ? 0 : 1);
			cout << endl;
			
			p = c;
		}
	}
}