#include <iostream>
#include <bitset>
using namespace std;
int s[10] = {63,6,91,79,102,109,125,39,127,111};
int main() {
	int n, m;
	while (cin >> n, ~n) {
		bitset<7> b(0);
        while (n--) {
			cin >> m;
			cout << (b^=s[m]) << endl;
			b = s[m];
		}
	}
}