Lenny is playing a game on a 3 × 3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched on then it will be switched off, if it was switched off then it will be switched on.

Lenny has spent some time playing with the grid and by now he has pressed each light a certain number of times. Given the number of times each light is pressed, you have to print the current state of each light.


-----Input-----

The input consists of three rows. Each row contains three integers each between 0 to 100 inclusive. The j-th number in the i-th row is the number of times the j-th light of the i-th row of the grid is pressed.


-----Output-----

Print three lines, each containing three characters. The j-th character of the i-th line is "1" if and only if the corresponding light is switched on, otherwise it's "0".


-----Examples-----
Input
1 0 0
0 0 0
0 0 1

Output
001
010
100

Input
1 0 1
8 8 8
2 0 3

Output
010
011
100

Difficulty: interview

Starter code:

Solutions:
a = []
b = []
for i in range(3):
      t =  input().split() 
      a.append([int(t[0]), int(t[1]), int(t[2]) ] )
      b.append([1, 1, 1])

def add(i, j, w):
      if 2>=i>=0 and 2>=j>=0:
            b[i][j] += w

for i in range(3):
      for j in range(3):
            add(i, j, a[i][j])
            add(i-1, j, a[i][j])
            add(i+1, j, a[i][j])
            add(i, j+1, a[i][j])
            add(i, j-1, a[i][j])

for i in range(3):
      print( ''.join( map(str, [ [0,1][b[i][j]%2 ] for j in range(3) ] ) ) )


arr = [1,1,1,1,1]
grid = []
for i in range(5):
    grid.append (list(arr))
#grid = [arr,arr,arr,arr,arr]

xc = [0,1,-1,0,0]
yc = [0,0,0,1,-1]

for i in range (1, 4):
    arr = list (map (int, input().split()))
    for j in range (1, 4):
        #print (str(i) + ' ' + str(j) + ' ' + str(arr[j-1]))
        for k in range (arr[j-1]):
            for l in range (5):
                #print (grid[i+xc[l]][j+yc[l]])
                grid[i+xc[l]][j+yc[l]] = 1 - grid[i+xc[l]][j+yc[l]]
                #print (grid)

    #print (grid)

for i in range (1, 4):
    print(str(grid[i][1]) + str(grid[i][2]) + str(grid[i][3]))


L=[]
L.append(list(map(int,input().split())))
L.append(list(map(int,input().split())))
L.append(list(map(int,input().split())))
L=L[0]+L[1]+L[2]
print((L[0]+L[1]+L[3]+1)%2,end="")
print((L[1]+L[0]+L[2]+L[4]+1)%2,end="")
print((L[2]+L[1]+L[5]+1)%2)
print((L[0]+L[3]+L[6]+L[4]+1)%2,end="")
print((L[1]+L[4]+L[7]+L[3]+L[5]+1)%2,end="")
print((L[2]+L[5]+L[8]+L[4]+1)%2)
print((L[6]+L[7]+L[3]+1)%2,end="")
print((L[7]+L[8]+L[6]+L[4]+1)%2,end="")
print((L[8]+L[7]+L[5]+1)%2)


t = [list(map(int, input().split())) for i in range(3)]
p = [[1] * 5 for i in range(5)]
for i in range(3):
    for j in range(3):
        if t[i][j] % 2 == 1:
            p[i][j + 1] += 1
            p[i + 2][j + 1] += 1
            for v in range(j, j + 3):
                p[i + 1][v] += 1
for i in range(1, 4):
    print(''.join(str(p[i][j] % 2) for j in range(1, 4)))


a = [[1]*3 for i in range(3)]
b = []
for i in range(3):
    b.append(list(map(int, input().split())))

for i in range(3):
    for j in range(3):
        b[i][j] %= 2

        if b[i][j] == 1:
            if i > 0: a[i-1][j] = 1 - a[i-1][j]
            if i < 2: a[i+1][j] = 1 - a[i+1][j]
            if j > 0: a[i][j-1] = 1 - a[i][j-1]
            if j < 2: a[i][j+1] = 1 - a[i][j+1]
            a[i][j] = 1 - a[i][j]

for i in range(3):
    print('%d%d%d' % (a[i][0], a[i][1], a[i][2]))



a=[[1,1,1],[1,1,1],[1,1,1]]
d={0:1,1:0}
for i in range(3):
    b=list(map(int,input().split()))
    for j in range(3):
        if b[j]%2==1:
            a[i][j]=d[a[i][j]]
            if i!=0:
                a[i-1][j]=d[a[i-1][j]]
            if i!=2:
                a[i+1][j]=d[a[i+1][j]]
            if j!=0:
                a[i][j-1]=d[a[i][j-1]]
            if j!=2:
                a[i][j+1]=d[a[i][j+1]]
for i in range(3):
    for j in range(3):
        print(a[i][j],end='')
    print()


__copyright__ = ''
__author__ = 'Son-Huy TRAN'
__email__ = "sonhuytran@gmail.com"
__doc__ = ''
__version__ = '1.0'


def main() -> int:
    lights = []
    results = [['', '', ''], ['', '', ''], ['', '', '']]

    for _ in range(3):
        lights.append([int(word) for word in input().split()])

    for i in range(3):
        for j in range(3):
            temp = lights[i][j] \
                   + (lights[i - 1][j] if i > 0 else 0) \
                   + (lights[i][j - 1] if j > 0 else 0) \
                   + (lights[i + 1][j] if i < 2 else 0) \
                   + (lights[i][j + 1] if j < 2 else 0)
            results[i][j] = str(1 - temp % 2)

    result_strings = [''.join(listi) for listi in results]
    print('\n'.join(result_strings))

    return 0


def __starting_point():
    exit(main())
__starting_point()

def change(n):
    if n == 0:
        n = 1
    else:
        n = 0
    return n

table = []
for i in range(3):
    table.append(list(map(int,input().split())))

row = [[1,1,1], [1,1,1], [1,1,1]]


for i in range(3):
    for j in range(3):
        if table[i][j] % 2 == 0:
            continue
        else:
            row[i][j] = change(row[i][j])
            if i == 0:
                if j == 0 :
                    row[i][j+1] = change(row[i][j+1])
                    row[i+1][j] = change(row[i+1][j])
                elif j == 1:
                    row[i][j+1] = change(row[i][j+1])
                    row[i][j-1] = change(row[i][j-1])
                    row[i+1][j] = change(row[i+1][j])
                elif j == 2:
                    row[i][j-1] = change(row[i][j-1])
                    row[i+1][j] = change(row[i+1][j])
            elif i == 1 :
                if j == 0 :
                    row[i][j+1] = change(row[i][j+1])
                    row[i-1][j] = change(row[i-1][j])
                    row[i+1][j] = change(row[i+1][j])
                elif j == 1 :
                    row[i][j+1] = change(row[i][j+1])
                    row[i][j-1] = change(row[i][j-1])
                    row[i+1][j] = change(row[i+1][j])
                    row[i-1][j] = change(row[i-1][j])
                elif j == 2 :
                    row[i][j-1] = change(row[i][j-1])
                    row[i+1][j] = change(row[i+1][j])
                    row[i-1][j] = change(row[i-1][j])
            elif i == 2 :
                if j == 0:
                    row[i][j+1] = change(row[i][j+1])
                    row[i-1][j] = change(row[i-1][j])
                elif j == 1 :
                    row[i][j+1] = change(row[i][j+1])
                    row[i][j-1] = change(row[i][j-1])
                    row[i-1][j] = change(row[i-1][j])
                elif j == 2 :
                    row[i-1][j] = change(row[i-1][j])
                    row[i][j-1] = change(row[i][j-1])

for i in range(3):
    rowo = ''
    for j in range(3):
        rowo += str(row[i][j])
    print(rowo)

from sys import stdin
def main():
	f1=[1,1,1]
	f2=[1,1,1]
	f3=[1,1,1]
	a=str(stdin.readline()).split()
	b=str(stdin.readline()).split()
	c=str(stdin.readline()).split()
	for i in range (3):
		a[i]=int(a[i])
		b[i]=int(b[i])
		c[i]=int(c[i])
	if (a[0]%2!=0):
		if (f1[0]==0):
			f1[0]=1
		else:
			f1[0]=0
		if (f2[0]==0):
			f2[0]=1
		else:
			f2[0]=0
		if (f1[1]==0):
			f1[1]=1
		else:
			f1[1]=0
	if (a[1]%2!=0):
		if (f1[0]==0):
			f1[0]=1
		else:
			f1[0]=0
		if (f1[1]==0):
			f1[1]=1
		else:
			f1[1]=0
		if (f2[1]==0):
			f2[1]=1
		else:
			f2[1]=0
		if (f1[2]==0):
			f1[2]=1
		else:
			f1[2]=0
	if (a[2]%2!=0):
		if (f1[1]==0):
			f1[1]=1
		else:
			f1[1]=0
		if (f1[2]==0):
			f1[2]=1
		else:
			f1[2]=0
		if (f2[2]==0):
			f2[2]=1
		else:
			f2[2]=0
	if (b[0]%2!=0):
		if (f1[0]==0):
			f1[0]=1
		else:
			f1[0]=0
		if (f2[0]==0):
			f2[0]=1
		else:
			f2[0]=0
		if (f3[0]==0):
			f3[0]=1
		else:
			f3[0]=0
		if (f2[1]==0):
			f2[1]=1
		else:
			f2[1]=0
	if (b[1]%2!=0):
		if (f2[0]==0):
			f2[0]=1
		else:
			f2[0]=0
		if (f1[1]==0):
			f1[1]=1
		else:
			f1[1]=0
		if (f2[1]==0):
			f2[1]=1
		else:
			f2[1]=0
		if (f3[1]==0):
			f3[1]=1
		else:
			f3[1]=0
		if (f2[2]==0):
			f2[2]=1
		else:
			f2[2]=0
	if (b[2]%2!=0):
		if (f2[1]==0):
			f2[1]=1
		else:
			f2[1]=0
		if (f1[2]==0):
			f1[2]=1
		else:
			f1[2]=0
		if (f2[2]==0):
			f2[2]=1
		else:
			f2[2]=0
		if (f3[2]==0):
			f3[2]=1
		else:
			f3[2]=0
	if (c[0]%2!=0):
		if (f2[0]==0):
			f2[0]=1
		else:
			f2[0]=0
		if (f3[0]==0):
			f3[0]=1
		else:
			f3[0]=0
		if (f3[1]==0):
			f3[1]=1
		else:
			f3[1]=0
	if (c[1]%2!=0):
		if (f3[0]==0):
			f3[0]=1
		else:
			f3[0]=0
		if (f2[1]==0):
			f2[1]=1
		else:
			f2[1]=0
		if (f3[1]==0):
			f3[1]=1
		else:
			f3[1]=0
		if (f3[2]==0):
			f3[2]=1
		else:
			f3[2]=0
	if (c[2]%2!=0):
		if (f3[1]==0):
			f3[1]=1
		else:
			f3[1]=0
		if (f2[2]==0):
			f2[2]=1
		else:
			f2[2]=0
		if (f3[2]==0):
			f3[2]=1
		else:
			f3[2]=0
	d=str(f1[0])
	e=str(f1[1])
	f=str(f1[2])
	g=str(f2[0])
	h=str(f2[1])
	i=str(f2[2])
	j=str(f3[0])
	k=str(f3[1])
	l=str(f3[2])
	print(d+e+f)
	print(g+h+i)
	print(j+k+l)
main()




from sys import stdin

board = None
deltar = [ -1, 0, 0, 1]
deltac = [ 0, -1, 1, 0]

def main():
  nonlocal board, deltar, deltac
  inp = stdin
  board = [ [ int(x) for x in inp.readline().strip().split() ] for i in range(3) ]
  ans = [ [ 0 for j in range(3) ] for i in range(3) ]
  for r in range(3):
    for c in range(3):
      ans[r][c] += board[r][c]
      for a in range(4):
        if 0<=r+deltar[a]<3 and 0<=c+deltac[a]<3:
          ans[r][c] += board[r+deltar[a]][c+deltac[a]]
  for r in range(3):
    print(''.join(str(1-(ans[r][c]%2)) for c in range(3)))

main()


import sys

inarray = []
outarray = [[1 for j in range(3)] for i in range(3)]
for i in range(3):
    k = [int(x) for x in (sys.stdin.readline()).split()]
    for j in range(3):
        if(k[j] % 2 != 0):
            outarray[i][j] ^= 1
            if(i - 1 >= 0):
                outarray[i - 1][j] ^= 1
            if(j - 1 >= 0):
                outarray[i][j - 1] ^= 1
            if(i + 1 < 3):
                outarray[i + 1][j] ^= 1
            if(j + 1 < 3):
                outarray[i][j + 1] ^= 1
            
for i in range(3):
    print("".join([str(x) for x in outarray[i]]))

arr = []
for i in range(3):
	arr.append([int(x) % 2 for x in input().split()])
ans = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	for j in range(3):
		cnt = 0
		visit = [[i, j], [i + 1, j], [i - 1, j], [i, j + 1], [i, j - 1]]
		for x, y in visit:
			if x < 0 or y < 0 or x > 2 or y > 2:
				continue
			cnt += arr[x][y]
		if cnt % 2:
			ans[i][j] = 0
print('\n'.join(''.join(str(x) for x in l) for l in ans))


def main():
    l = [list(map(int, input().strip().split())) for _ in range(3)]
    field = [[1] * 3 for _ in range(3)]
    for y in range(3):
        for x in range(3):
            if l[y][x] & 1:
                for i in range(max(y - 1, 0), min(y + 2, 3)):
                    field[i][x] ^= 1
                for j in range(max(x - 1, 0), min(x + 2, 3)):
                    field[y][j] ^= 1
                field[y][x] ^= 1
    for _ in range(3):
        print(''.join(map(str, field[_])))


main()

'''
Created on Jan 28, 2015

@author: RedNextYear
'''
t = [list(map(int, input().split())) for i in range(3)]
p = [[1] * 5 for i in range(5)]
for i in range(3):
    for j in range(3):
        if t[i][j] % 2 == 1:
            p[i][j + 1] += 1
            p[i + 2][j + 1] += 1
            for v in range(j, j + 3):
                p[i + 1][v] += 1
for i in range(1, 4):
    print(''.join(str(p[i][j] % 2) for j in range(1, 4)))


# coding: utf-8
light = [[0,0,0,0,0] for i in range(5)]
for i in range(1,4):
    s = [int(i) for i in input().split()]
    for j in range(1,4):
        light[i][j] += s[j-1]
        light[i-1][j] += s[j-1]
        light[i+1][j] += s[j-1]
        light[i][j-1] += s[j-1]
        light[i][j+1] += s[j-1]
for i in range(1,4):
    for j in range(1,4):
        if light[i][j]%2==1:
            print(0,end='')
        else:
            print(1,end='')
    print()


lix = [[int(x) for x in input().split()] for y in range(3) ]
bulbs = [[ "1" for x in range(3)] for y in range(3)]
moves = [(0,0),(1,0),(-1,0),(0,1),(0,-1)]
for x in range(3):
    for y in range(3):
        if lix[x][y] & 1:
            for a,b in moves:
                if (x+a <3 and x+a>-1) and (y+b <3 and y+b>-1):
                    bulbs[x+a][y+b] ="0" if int(bulbs[x+a][y+b]) else "1"


print("\n".join(["".join(li) for li in bulbs]))





l=[]
for i in range(3):
    l1=input().split()
    for j in range(3):
        l1[j]=int(l1[j])
    l.append(l1)

for i in range(3):
    for j in range(3):
        c=l[i][j]
        if(i>0):
            c+=l[i-1][j]
        if(j>0):
            c+=l[i][j-1]
        if(i<2):
            c+=l[i+1][j]
        if(j<2):
            c+=l[i][j+1]
        if(c%2==0):
            print(1,end="")
        else:
            print(0,end="")
    print()







arr = [[int(i) % 2 for i in input().split()] for _ in range(3)]
state = [[1] * 3 for i in range(3)]
dirs = [(0, 1), (0, -1), (1, 0), (-1, 0)]
for y in range(3):
    for x in range(3):
        state[y][x] ^= arr[y][x]
        for dy, dx in dirs:
            j, i = y + dy, x + dx
            if 0 <= j < 3 and 0 <= i < 3:
                state[y][x] ^= arr[j][i]
for row in state:
    print(*row, sep='')


a,b,c=list(map(int,input().split()))
e,f,g=list(map(int,input().split()))
m,n,l=list(map(int,input().split()))
p=1
q=1
r=1
s=1
t=1
u=1
v=1
w=1
x=1
k=[p,q,r,s,t,u,v,w,x]
j=[a,b,c,e,f,g,m,n,l]
def change(l,h):
    kas=l[h] 
    if kas==1:
        l[h]=0
    if kas==0:
        l[h]=1
    


for d in range(3): 
    if j[d]%2!=0 and j[d]!=0:
        change(k,d)
        if d!=2:
            change(k,d+1)
        if d!=0:
            change(k,d-1)
        #if d!=1:
            #change(k,4)
        change(k,d+3)
        #if d==1:
            #change(k,d+2)
            #change(k,d+4)
        
for d in range(3,6): 
    if j[d]%2!=0 and j[d]!=0:
        change(k,d)
        if d!=5:
            change(k,d+1)
            
        if d!=3:
            change(k,d-1)
        change(k,d+3)
        change(k,d-3)
        #if d==4:
            #change(k,d+2)
            #change(k,d-4)
            #change(k,d+4)
            #change(k,d-2)
        #if d==3:
            #change(k,d+4)
            #change(k,d-2)
        #if d==5:
            #change(k,d-4)
            #change(k,d+2)
        
for d in range(6,9): 
    if j[d]%2!=0 and j[d]!=0:
        change(k,d)
        if d!=8:
            change(k,d+1)
        if d!=6:
            change(k,d-1)
        #if d!=7:
            #change(k,4)
        change(k,d-3)
        #if d==7:
            #change(k,d-2)
            #change(k,d-4)
S0=str(k[0])
S1=str(k[1])
S2=str(k[2]) 
S3=str(k[3])
S4=str(k[4])
S6=str(k[6])
S5=str(k[5])
S7=str(k[7])
S8=str(k[8])

print(S0+S1+S2)
print(S3+S4+S5)
print(S6+S7+S8)


def do(sh):
    return 1-sh


a = [[1 for _ in range(5)] for __ in range(5)]
for i in range(1, 4):
    b = list(map(int, input().split()))
    for j in range(1, 4):
        if b[j-1] % 2 == 1:
            a[i][j] = 1-a[i][j]
            a[i+1][j] = 1-a[i+1][j]
            a[i-1][j] = 1-a[i-1][j]
            a[i][j+1] = 1-a[i][j+1]
            a[i][j-1] = 1-a[i][j-1]
print("\n".join(["".join(map(str, line[1:-1])) for line in a[1:-1]]))


def get_neighbors(i, j):
    neighbors = []
    for x in range(-1, 2):
        for y in range(-1, 2):
            if x != y:
                if x == 0 or y == 0:
                    if x + i >= 0 and y + j >= 0 and x + i <= 2 and y + j <= 2:
                        neighbors.append((x + i, y + j))
    return neighbors



def lights_out(lst):
    res = [x[:] for x in lst]
    for i in range(len(lst)):
        for j in range(len(lst[i])):
            for x, y in get_neighbors(i, j):
                res[i][j] += lst[x][y]

    return res

def __starting_point():
    lst = [0, 0, 0]
    for i in range(3):
        lst[i] = [int(x) for x in input().split()]
    res = lights_out(lst)
    for line in res:
        for entry in line:
            print((entry + 1) % 2, end='')
        print()

__starting_point()

G = [[1]*5 for i in range(5)]

D = [(0,0),(-1,0),(1,0),(0,-1),(0,1)]

def toggle(i,j):
    for d in D :
        G[i+d[0]][j+d[1]] = 1 - G[i+d[0]][j+d[1]]

for i in range(1,4):
    n = list(map(int,input().split()))
    for j in range(1,4):
        if n[j-1] % 2 == 1 :
            toggle(i,j)

for i in range(1,4):
    for j in range(1,4):
        print(G[i][j],end='')
    print()

l=[[0]*5]+[[0]+list(map(int,input().split()))+[0] for _ in range(3)]+[[0]*5]
ans=[['']*3 for _ in range(3)]
for i in range(1,4):
    for j in range(1,4):
        ans[i-1][j-1]=str(1-((l[i][j]+l[i][j-1]+l[i][j+1]+l[i-1][j]+l[i+1][j])%2))
print('\n'.join(map(''.join,ans)))

s=[[1]*5 for _ in range(5)]
for i in 1,2,3:
	for j,v in zip((1,2,3),map(int,input().split())):
		for k,d in (-1,0),(1,0),(0,-1),(0,1),(0,0):
			s[i+k][j+d]+=v
for i in 1,2,3:
	for j in 1,2,3:
		print(s[i][j]%2,end='')
	print()