#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;
int n, m;
vector<int> vege;

const int INF = 1 << 29;

int main(void)
{
	//0111111 0000110 1011011 1001111 1100110 1101101 1111101 0100111 1111111 1101111
	int memo[] = {127 - 64, 6, 64 + 16 + 8 + 2 + 1, 64 + 15, 64 + 32 +4 + 2,64+32+8+4+1,127-2, 32+7,127,127-16 };
	int nisin[] = {64, 32, 16, 8, 4, 2, 1};
	while(cin >> n && n != -1)
	{
		int bit = 0;
		for (int i = 0; i < n; i++)
		{
			int a;
			cin >> a;
			int ans = bit ^ memo[a];
			bit = memo[a];
			for (int j = 0; j < 7; j++)
			{
				if(ans >= nisin[j])
				{
					ans -= nisin[j];
					cout << 1;
				}
				else cout << 0;
			}
			cout << endl;
		}
	}
	return 0;
}