import std.stdio;
import std.array;
import std.conv;

void binarywrite(int n){
	for(int i=6;i>=0;i--){
		write(n >> i & 1);
	}
	writeln("");
}

void main(){
	string s;
	int[] lights = [0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x27, 0x7f, 0x6f];
	int n = 0;
	while(s = readln(), ~(n = s[0..s.length-1].to!(int))){
		int prev_j = 0;
		for(int i=n;i;i--){
			s = readln();
			int j = s[0..s.length-1].to!(int);
			binarywrite(prev_j ^ lights[j]);
			prev_j = lights[j];
		}
	}
	return;
}