b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);}