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++: #include<bits/stdc++.h>
using namespace std;
main(){
  unsigned long num[11]={63,6,91,79,66,109,125,39,127,111,0};
  int n,a,b=10;
  while(cin>>n,n!=-1){
    bitset<7> now((unsigned long)0);
    b=10;
    for(int i=0;i<n;i++){
      cin>>a;
      now=num[b]^num[a];
      for(int i=6;i>=0;i--){
	cout<<now[i];
      }
      cout<<endl;
      b=a;
    }
  }
}

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

char dig[10][8] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
char dc[10][10][8];
int main() {
	int n, num, buf;
	for(int i=0; i<10; ++i) for(int j=0; j<10; ++j) {
		for(int k=0; k<7; ++k) dc[i][j][k] = '0'+((dig[i][k]-'0')^(dig[j][k]-'0')); dc[i][j][7] = 0;
	}
	while(1) {
		cin >> n; if(n==-1) break;
		buf = -1;
		for(int i=0; i<n; ++i) {
			cin >> num;
			cout << (buf==-1?dig[num]:dc[buf][num]) << endl;
			buf = num;
		}
	}
	return 0;
}

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", "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 <iostream>
#include <vector>
#include <bitset>
using namespace std;

int main() {
  vector<int> bs = {0x0, 0x3f, 0x6, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x27, 0x7f, 0x6f}; // two based
  int n;
  while(cin >> n, n >= 0) {
    int lastnum = -1;
    for(int i = 0; i < n; ++i) {
      int num;
      cin >> num;
      cout << static_cast<bitset<7> >(bs[num + 1] ^ bs[lastnum + 1]) << endl;
      lastnum = num;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int n,s;
  string san[10];
  san[0]="0111111"; 
  san[1]="0000110";
  san[2]="1011011";
  san[3]="1001111";
  san[4]="1100110";
  san[5]="1101101";
  san[6]="1111101";
  san[7]="0100111";
  san[8]="1111111";
  san[9]="1101111";
  while(cin>>n){
    if(n==-1) break;
    string mem;
    for(int i=0;i<n;i++){
      cin >> s;
      if(i==0){
	cout << san[i] << endl;
	mem = san[i];
      }
      else{
	for(int i=0;i<7;i++){
	  if(san[s][i]==mem[i]) cout << '0';
	  else cout << '1';
	}
	cout << endl;
	mem = san[s];
      }
    }
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
string c[10]={
	"0111111",
	"0000110",
	"1011011",
	"1001111",
	"1100110",
	"1101101",
	"1111101",
	"0100111",
	"1111111",
	"1101111"
};
int n;
main()
{
	while(cin>>n,n)
	{
		string s="0000000";
		for(;n--;)
		{
			int d;cin>>d;
			for(int j=0;j<7;j++)
			{
				cout<<(s[j]!=c[d][j]);
				s[j]=c[d][j];
			}
			cout<<endl;
		}
	}
}

C++: #include <algorithm>
#include <iostream>

using namespace std;

//  g, f, e, d, c, b, a
int ss[10][7] = {
  { 0, 1, 1, 1, 1, 1, 1 },
  { 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 }
};

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == -1) return 0;
    int d[7];
    fill(d, d+7, 0);
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      for (int j = 0; j < 7; j++) {
        cout << (d[j] ^ ss[x][j]);
        d[j] = ss[x][j];
      }
      cout << endl;
    }
  }
}

C++: // This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bitset>
using namespace std;

int main()
{ 
    unsigned int bit[10];
    unsigned int ans = 0;
    
    bit[0] = 0b0111111;
    bit[1] = 0b0000110;
    bit[2] = 0b1011011;
    bit[3] = 0b1001111;
    bit[4] = 0b1100110;
    bit[5] = 0b1101101;
    bit[6] = 0b1111101;
    bit[7] = 0b0100111;
    bit[8] = 0b1111111;
    bit[9] = 0b1101111;
    int n, i;
    while(true){
    cin >> n;
    if(n==-1)break;
    int d[n];
    for(i=0; i<n; i++)cin >> d[i];
    ans = 0;
    cout << bitset<7> (ans ^ bit[d[0]]) << endl;
    for(i=1; i<n; i++){
        ans = bit[d[i-1]] ^ bit[d[i]];
        cout << bitset<7> (ans) << endl;
    }
    }
    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/

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

int main(){
  vector<string> seg;
  int n, s;

    seg.push_back("0111111"); // 0
    seg.push_back("0000110"); // 1
    seg.push_back("1011011"); // 2
    seg.push_back("1001111"); // 3
    seg.push_back("1100110"); // 4 
    seg.push_back("1101101"); // 5 
    seg.push_back("1111101"); // 6 
    seg.push_back("0111111"); // 7
    seg.push_back("1111111"); // 8
    seg.push_back("1101111"); // 9


  while(cin >> n){
    if(n < 0) return 0;
    string start="0000000",ans="0000000";
    for(int i=0; i<n; i++){
      cin >> s;
      string result = seg[s];

      // cout << "start:  " << start << endl;
      // cout << "result: " << result << endl;

      for(int j=0; j<7; j++){
	if(start[j] == result[j]) ans[j] = '0';
	else ans[j] = '1';
      }

      for(int i=0; i<7; i++)
	cout <<  ans[i]-'0';
      cout << endl;
      start = seg[s];
    }

  }
}

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

int main()
{
	const int seg[] = {0x3f, 0x6, 0xb, 0x4f, 0x66, 0x6d, 0x7d, 0x27, 0x7f, 0x6f};
	int n;
	
	while (cin >> n, n != -1){
		int res = 0;
		int num;
		for (int i = 0; i < n; i++){
			cin >> num;
			cout << bitset<7>(res^seg[num]) << endl;
			res = seg[num];
		}
	}
	return (0);
}