#include<iostream>
#include<string>
using namespace std;
string bin(int n){
int i;
string s="       ";
for(i=0;i<7;i++){
if(n%2==0)s[6-i]='0';else s[6-i]='1';
n>>=1;
}
return s;
}
int main(){
int n,i,j,k,p[10]={63,6,91,79,102,109,125,39,127,111};
while(cin>>n){
if(n==-1)break;
for(i=0;i<n;i++){
k=j;cin>>j;
if(i>0)cout<<bin(p[j]^p[k])<<endl;
else cout<<bin(p[j])<<endl;
}
}
return 0;
}