Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	table := [][]int{ // abcdefgの順番の
	{1,1,1,1,1,1,0}, // 1
	{0,1,1,0,0,0,0}, // 2
	{1,1,0,1,1,0,1}, // 3
	{1,1,1,1,0,0,1}, // 4
	{0,1,1,0,0,1,1}, // 5
	{1,0,1,1,0,1,1}, // 6
	{1,0,1,1,1,1,1}, // 7
	{1,1,1,0,0,1,0}, // 8
	{1,1,1,1,1,1,1}, // 9
	{1,1,1,1,0,1,1}, // 10
	}
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == -1 {
			break
		}
		initial := []int{0,0,0,0,0,0,0}
		for i := 0; i < n; i++ {
			scanner.Scan()
			d, _ := strconv.Atoi(scanner.Text())
			for j := 6; j >= 0; j-- {
				fmt.Printf("%d", initial[j]^table[d][j])
				initial[j] = table[d][j]
			}
			fmt.Println()
		}
	}
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  vs v = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111"};
  while (cin >> n, n != -1) {
    string s = "0000000";
    while (n--) {
      int d;
      cin >> d;
      string t = v[d], diff = "";
      rep(i, 7) diff += s[i] == t[i] ? "0" : "1";
      cout << diff << endl;
      s = t;
    }
  }
}

C++: #include <bits/stdc++.h>

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

#include <iostream>
#include <iomanip>
#include <cmath>
 
using namespace std;

const int b[]={
    0b0111111,
    0b0000110,
    0b1011011,
    0b1001111,
    0b1100110,

    0b1101101,
    0b1111101,
    0b0100111,
    0b1111111,
    0b1101111
};
 
void print(int n){
    cout << (bitset<7>(n)) << endl;
}

int main(){
    int n;
    while(cin >> n && n!=-1){
        vi v(n);
        rep(i,n) cin >> v[i];
        rep(i,n){
            if(i==0) print(0^b[v[i]]);
            else print(b[v[i-1]]^b[v[i]]);
        }
    }
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

const char *disp[10] = {
  "1111110",
  "0110000",
  "1101101",
  "1111001",
  "0110011",
  "1011011",
  "1011111",
  "1110010",
  "1111111",
  "1111011",
};

char myxor(char a, char b){
  return (a != b)  ? '1' : '0';
}

int main(){
  int n;
  while(scanf("%d", &n), n != -1){
    char b[7]; REP(i,7) b[i] = '0';
    REP(i,n){
      int t;
      scanf("%d", &t);
      REP(j,7){
        putchar(b[6-j] = myxor(b[6-j], disp[t][6-j]));
      }
      puts("");
    }
  }
  return 0;
}

C++: // 2011/07/27 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int seg[11][7] = {{0,1,1,1,1,1,1},	// eÌf[^
	                  {0,0,0,0,1,1,0},
	                  {1,0,1,1,0,1,1},
	                  {1,0,0,1,1,1,1},
	                  {1,1,0,0,1,1,0},
	                  {1,1,0,1,1,0,1},
	                  {1,1,1,1,1,0,1},
	                  {0,1,0,0,1,1,1},
	                  {1,1,1,1,1,1,1},
	                  {1,1,0,1,1,1,1},
	                  {0,0,0,0,0,0,0}};	// seg[10]Íñ\¦

	while(true){
		int n;
		cin >> n;
		if(n==-1)
			break;

		int cur = 10;		// ¡ÌiúlÍñ\¦j
		int nxt;		// Ì
		for(int i=0; i<n; i++){
			cin >> nxt;
			for(int j=0; j<7; j++)
				cout << (seg[cur][j]+seg[nxt][j])%2;	// r¼I_a
			cout << endl;
			cur = nxt;
		}
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

string s[10]={"1111110",
			  "0110000",
			  "1101101",
			  "1111001",
			  "0110011",
			  "1011011",
			  "1011111",
			  "1110010",
			  "1111111",
			  "1111011"};

signed main() {
	int n;
	while(1){
		cin >> n;
		if(n == -1) break;
		int a;
		string now = "0000000";
		rep(i, 0, n){
			cin >> a;
			string ans = "";
			repb(j, 6, 0){
				if(now[j] != s[a][j]) cout<< 1;
				else cout<< 0;
			}
			cout << endl;
			now = s[a];
		}
	}
}

C++: #include <iostream>
#include <string>
using namespace std;

string seg[]={"1111110","0110000","1101101","1111001","0110011","1011011","1011111","1110010","1111111","1111011"};

int str2int(string str)
{
	int ret=0,dig=1;
	for(int i=0; i<7; i++)
	{
		ret+=(str[i]-'0')*dig;
		dig*=2;
	}

	return ret;
}

void output(int a)
{
	int dig=(1<<6);
	string ret;
	for(int i=0; i<7; i++)
	{
		ret+=(a/dig + '0');
		a%=dig;
		dig/=2;
	}

	cout << ret  << endl;
}

int main()
{
	int N;
	while(cin >> N, N!=-1)
	{
		int stat=0;
		while(N--)
		{
			int t;
			cin >> t;
			output(stat^str2int(seg[t]));
			stat = str2int(seg[t]);
		}

	}
}