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()
		}
	}
}

Python: # AOJ 0228: Seven Segments
# Python3 2018.6.25 bal4u
 
p = [[1,1,1,1,1,1,0], [0,1,1,0,0,0,0], [1,1,0,1,1,0,1], [1,1,1,1,0,0,1], [0,1,1,0,0,1,1], \
     [1,0,1,1,0,1,1], [1,0,1,1,1,1,1], [1,1,1,0,0,1,0], [1,1,1,1,1,1,1], [1,1,1,1,0,1,1]]
 
while True:
    n = int(input())
    if n < 0: break
    a = [0]*7
    for i in range(n):
        d = int(input())
        ans = ''
        for j in range(6,-1,-1):
            k = (a[j] ^ p[d][j]) & 1
            ans += '1' if k else '0'
            if k: a[j] = 1-a[j]
        print(ans)

Python: NUM = (
        0b0111111,
        0b0000110,
        0b1011011,
        0b1001111,
        0b1100110,
        0b1101101,
        0b1111101,
        0b0100111,
        0b1111111,
        0b1101111,
        )

while 1:
    n = int(input())
    if n == -1:break

    current = 0
    for i in range(n):
        num = NUM[int(input())]
        print(format(current ^ num,'b').zfill(7))
        current = num

Python: ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=input()
	if n==-1:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Python: Num_seg = [[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]]
while True:
    n = int(input())
    if n == -1:
        break
    num_b = int(input())
    seg = ""
    for h in range(7):
        seg = seg + str(Num_seg[num_b][h])
    
    print(seg)
    for i in range(n - 1):
        num_a = int(input())
        seg = ""
        for j in range(7):
            if Num_seg[num_b][j] == Num_seg[num_a][j]:
                seg = seg + "0"
            else:
                seg = seg + "1"
        num_b = num_a
    
        print(seg)

Python: seg = [[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]]

while True :
    n = int(input())
    if n == -1 :
        break
    pre = [0]*7
    for i in range(n) :
        num = int(input())
        post = seg[num]
        for j in range(7) :
            if pre[j] == post[j] :
                print(0, end='')
            else :
                print(1, end='')
        print()
        pre = post

Python: import sys
f = sys.stdin

segment =[0b0111111,
0b0000110,
0b1011011,
0b1001111,
0b1100110,
0b1101101,
0b1111101,
0b0100111,
0b1111111,
0b1101111]

while True:
    n = int(f.readline())
    if n == -1:
        break
        
    display = 0
    for i in [int(f.readline()) for _ in range(n)]:
        print(bin(display ^ segment[i])[2:].zfill(7))
        display = segment[i]

Python: #!/usr/bin/env python3

seven_seg = {
        0: '0111111',
        1: '0000110',
        2: '1011011',
        3: '1001111',
        4: '1100110',
        5: '1101101',
        6: '1111101',
        7: '0100111',
        8: '1111111',
        9: '1101111'
        }

while True:
    seven_seg_state = ['0'] * 7
    n = int(input())
    if n == -1:
        break
    for _ in range(n):
        in_data = int(input())
        for i, s in enumerate(seven_seg_state):
            if seven_seg[in_data][i] == s:
                print("0", end="")
            else:
                print("1", end="")
            s = seven_seg[in_data][i]

        print()

Python: # Aizu Problem 0228: Seven Segments

import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


digits = [63, 6, 91, 79, 102, 109, 125, 39, 127, 111]

while True:
    n = int(input())
    if n == -1:
        break
    e = 0
    for i in range(n):
        a = digits[int(input())]
        print("{:07b}".format(a^e))
        e = a

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0228

"""
import sys
from sys import stdin
input = stdin.readline


LED_pattern = [
    ##-gfedcba
    0b0111111,                #  0
    0b0000110,                #  1
    0b1011011,                #  2
    0b1001111,                #  3
    0b1100110,                #  4
    0b1101101,                #  5
    0b1111101,                #  6
    0b0100111,                #  7
    0b1111111,                #  8
    0b1101111,                #  9
    0b0000000                 #  all OFF
]


def solve(cp, np):
    a = LED_pattern[cp]
    b = LED_pattern[np]
    return bin(a ^ b)[2:].zfill(7)


def main(args):
    while True:
        n = int(input())
        if n == -1:
            break
        cp = 10                 #  all OFF
        for _ in range(n):
            d = int(input())
            ans = solve(cp, d)
            cp = d
            print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: s=[0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0100111,0b1111111,0b1101111]
while 1:
    n=int(input())
    if n<0:break
    a=0
    for _ in range(n):
        b=int(input())
        print(bin(a^s[b])[2:].zfill(7))
        a=s[b]

Python: dic = {0:"0111111", 1:"0000110", 2:"1011011", 3:"1001111", 4:"1100110",
       5:"1101101", 6:"1111101", 7:"0100111", 8:"1111111", 9:"1101111"}

while True:
  n = int(input())
  if n == -1:
    break
  dig = "0" * 7
  for _ in range(n):
    d = dic[int(input())]
    put = ""
    for i in range(7):
      if dig[i] != d[i]:
        put += "1"
      else:
        put += "0"
    print(put)
    dig = d

Python: ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n<0:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Python: ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==0:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Python: ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==-1:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Python: #!/usr/bin/env python3

seven_seg = {
        0: '0111111',
        1: '0000110',
        2: '1011011',
        3: '1001111',
        4: '1100110',
        5: '1101101',
        6: '1111101',
        7: '0100111',
        8: '1111111',
        9: '1101111'
        }

while True:
    seven_seg_state = ['0'] * 7
    n = int(input())
    if n == -1:
        break
    for _ in range(n):
        in_data = int(input())
        for i in range(7):
            if seven_seg[in_data][i] == seven_seg_state[i]:
                print("0", end="")
            else:
                print("1", end="")
            seven_seg_state[i] = seven_seg[in_data][i]

        print()

Python: nums = ["0111111", "0000110", "1011011", "1001111", "1100110",
        "1101101", "1111101", "0100111", "1111111", "1101111"]

while 1:
    n = int(input())
    if n == -1:
        break

    sig = "0000000"
    for _ in range(n):
        d = int(input())
        num = nums[d]
        out = ""
        for s, n in zip(sig, num):
            if s == n:
                out += "0"
            else:
                out += "1"

        print(out)
        sig = num