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.

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.

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".

def read_int_row ( ):
	return [int(x) for x in input().split()]

l1 = 0b110100000
l2 = 0b111010000
l3 = 0b011001000

l4 = 0b100110100
l5 = 0b010111010
l6 = 0b001011001

l7 = 0b000100110
l8 = 0b000010111
l9 = 0b000001011

lights = [[l1, l2, l3],
		  [l4, l5, l6],
		  [l7, l8, l9]]

base_board = 0b111111111

board = []

for _ in range(3):
	board.append(read_int_row())

for i, row in enumerate(board):
	for j, c in enumerate(row):
		board[i][j] = c % 2

for i, row in enumerate(board):
	for j, c in enumerate(row):
		if board[i][j] == 1:
			base_board ^= lights[i][j]

p_board = format (base_board, '#011b').replace("0b", "")

print (p_board[:3])
print (p_board[3:6])
print (p_board[6:])

ri = lambda: raw_input().strip()

grid = []
line_1 = map(int, ri().split())
line_2 = map(int, ri().split())
line_3 = map(int, ri().split())

grid.append(line_1)
grid.append(line_2)
grid.append(line_3)

result = [[0,0,0],[0,0,0],[0,0,0]]

maxRow = len(grid)
maxColumn = len(line_1)

for rowIndex in range(len(grid)):
    ll = grid[rowIndex]

    for columnIndex in range(len(ll)):
        val = ll[columnIndex]

        result[rowIndex][columnIndex] += val

        if rowIndex - 1 >= 0:
            result[rowIndex-1][columnIndex] += val

        if rowIndex + 1 < maxRow:
            result[rowIndex+1][columnIndex] += val

        if columnIndex - 1 >= 0:
            result[rowIndex][columnIndex-1] += val

        if columnIndex + 1 < maxColumn:
            result[rowIndex][columnIndex+1] += val

strRes = ''
for line in result:
    for i in line:
        if i % 2 == 0:
            strRes += '1'
        else:
            strRes += '0'
    print strRes
    strRes = ''

l = []

for x in range(0, 3) :

    l.append(map(int, raw_input().split()))

for x in range(0, 3) :

    s = ''

    for y in range(0, 3) :

        count = 0

        for p in range(0, 3) :

            for q in range(0, 3) :

                if ( x==p and abs(y-q)<=1 ) or ( y==q and abs(x-p)<=1 ) :

                    count = count + l[p][q]

        if count % 2 == 0 :

            s = s + '1'

        else :

            s = s + '0'

    print s

def toggle(pos, count):
    i = int(pos[0])
    j = int(pos[1])

    if count % 2 != 0:
        if data[i][j] == 0:
            data[i][j] = 1
            return True
        elif data[i][j] == 1:
            data[i][j] = 0
            return True
    else:
        return False

data = [[1, 1, 1],
        [1, 1, 1],
        [1, 1, 1]]
number = []
n = 3
[number.append(input().split(" ")) for i in range (n)]
for i in range (n):
    for j in range (n):
        count = int(number[i][j])
        pos = [i, j]
        toggle(pos, count)

        if i-1 < 0:
            if j-1 < 0:
                pos = [i, j+1]
                toggle(pos, count)
                pos = [i+1, j]
                toggle(pos, count)
            elif j+1 > n-1:
                pos = [i, j-1]
                toggle(pos, count)
                pos = [i+1, j]
                toggle(pos, count)
            else:
                pos = [i+1, j]
                toggle(pos, count)
                pos = [i, j-1]
                toggle(pos, count)
                pos = [i, j+1]
                toggle(pos, count)
        elif i+1 > n-1:
            if j+1 > n-1:
                pos = [i, j-1]
                toggle(pos, count)
                pos = [i-1, j]
                toggle(pos, count)
            elif j-1 < 0:
                pos = [i-1, j]
                toggle(pos, count)
                pos = [i, j+1]
                toggle(pos, count)
            else:
                pos = [i, j-1]
                toggle(pos, count)
                pos = [i, j+1]
                toggle(pos, count)
                pos = [i-1, j]
                toggle(pos, count)
        else:
            if j-1 < 0:
                pos = [i, j+1]
                toggle(pos, count)
                pos = [i-1, j]
                toggle(pos, count)
                pos = [i+1, j]
                toggle(pos, count)
            elif j+1 > n-1:
                pos = [i, j-1]
                toggle(pos, count)
                pos = [i-1, j]
                toggle(pos, count)
                pos = [i+1, j]
                toggle(pos, count)
            else:
                pos = [i-1, j]
                toggle(pos, count)
                pos = [i+1, j]
                toggle(pos, count)
                pos = [i, j-1]
                toggle(pos, count)
                pos = [i, j+1]
                toggle(pos, count)
for i in range (n):
    for j in range (n):
        print(data[i][j], end = '')
    print()

import sys
import math
import bisect

def solve(A):
    n = len(A)
    B = []
    for i in range(n):
        B.append([1] * n)
    for i in range(n):
        for j in range(n):
            A[i][j] %= 2
            if A[i][j]:
                B[i][j] ^= 1
                if i - 1 >= 0:
                    B[i-1][j] ^= 1
                if i + 1 < n:
                    B[i+1][j] ^= 1
                if j - 1 >= 0:
                    B[i][j-1] ^= 1
                if j + 1 < n:
                    B[i][j+1] ^= 1
    return B

def main():
    A = []
    for i in range(3):
        A.append(list(map(int, input().split())))
    ans = solve(A)
    for i in range(len(ans)):
        print(''.join(list(str(a) for a in ans[i])))

if __name__ == "__main__":
    main()

def calc(grid):
    n = [["1" for y in range(3)] for x in range(3)]
    for row in range(len(grid)):
        for col in range(len(grid[0])):
            update(n, grid, row, col)
    return n
def update(n, grid, row, col):
    c = grid[row][col]
    c %=2
    if c != 0:
        # toggle adjacent lights
        for nr, nc in zip([row-1, row+1, row, row], [col, col, col-1,col+1]):
            if nr>=0 and nr<len(n) and nc>=0 and nc<len(n[0]):
                n[nr][nc] = "1" if n[nr][nc] == "0" else "0"
        n[row][col] = "1" if n[row][col] == "0" else "0"

# get inputs
grid = []
for _ in range(3):
    grid.append(list(map(int, input().split())))
n = calc(grid)
for row in n:
    print(''.join(row))

ans=[[1 for i in range(3)] for j in range(3)]
q=[]
for i in range(3):
	q.append(list(map(int,input().split())))
for i in range(3):
	for j in range(3):
		if(q[i][j]%2==1):
			ans[i][j]=ans[i][j]^1
			if(i-1>=0):
				ans[i-1][j]=ans[i-1][j]^1
			if(i+1<3):
				ans[i+1][j]=ans[i+1][j]^1
			if(j-1>=0):
				ans[i][j-1]=ans[i][j-1]^1
			if(j+1<3):
				ans[i][j+1]=ans[i][j+1]^1

for i in range(3):
	for j in range(3):
		print(ans[i][j],end='')
	print('')

b =[[0 for i in range(5)] for j in range(5)]
for i in range(1,4):
    b[i][1:4] = [int(x)%2 for x in input().split()]
for i in range(1,4):
    for j in range(1,4):
        print((1+b[i][j] + b[i-1][j]+b[i+1][j]+b[i][j-1]+b[i][j+1])%2, end='')
    print()

import sys
input = sys.stdin.readline

############ ---- Input Functions ---- ############
#  — For taking integer inputs.
def inp():
    return(int(input()))
    # — For taking List inputs.
def inlt():
    return(list(map(int,input().split())))
    #  For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
    # — For taking space seperated integer variable inputs.
def invr():
    return(map(int,input().split()))
# --------------------------------------------------
grid = [
    [1,1,1],
    [1,1,1],
    [1,1,1],
]
inputGrid = []
for x in range(3):
    inputGrid.append(list(invr()))
for x in range(3):
    for i in range(3):
        num = inputGrid[x][i]
        for c in range(num):
            grid[x][i] = 1 - grid[x][i]
            if x+1 < 3:
                grid[x+1][i] = 1 - grid[x+1][i]
            if x-1 >= 0:
                grid[x-1][i] = 1 - grid[x-1][i]
            if i-1 >= 0:
                grid[x][i-1] = 1 - grid[x][i-1]
            if i+1 < 3:
                grid[x][i+1] = 1 - grid[x][i+1]
for x in range(3):
    print(''.join(map(str,grid[x])))

l=[]
for i in range(3):
   l.append(list(map(int,input().split(" "))))
for i in range(3):
    for j in range(3):
        s=l[i][j]
        if j-1>=0:
            s+=l[i][j-1]
        if j+1<3:
            s+=l[i][j+1]
        if i-1>=0:
            s+=l[i-1][j]
        if i+1<3:
            s+=l[i+1][j]
        if s%2==0:
            print("1",end="")
        else:
            print("0",end="")
    print()

import sys
u = sys.stdin.read().split('\n')
arr = []
light = [[1,1,1], [1,1,1], [1,1,1]]
for line in u:
    c = []
    for x in line.split():
        if int(x) %2 == 0:
            c.append(0)
        else:
            c.append(1)
    arr.append(c)
for i,row in enumerate(arr):
    for j,a in enumerate(row):
        if a == 1:
            if light[i][j] == 1:
                light[i][j] = 0
            else:
                light[i][j] = 1
            if i+1 != 3:
                if light[i + 1][j] == 1:
                    light[i +1][j] = 0
                else:
                    light[i+1][j] = 1
            if i-1 != -1:
                if light[i-1][j] == 1:
                    light[i-1][j] = 0
                else:
                    light[i-1][j] = 1
            if j-1 != -1:
                if light[i][j-1] == 1:
                    light[i][j-1] = 0
                else:
                    light[i][j-1] = 1
            if j+1 != 3:
                if light[i][j+1] == 1:
                    light[i][j+1] = 0
                else:
                    light[i][j+1] = 1

for li in light:
    c = ""
    for a in li:
        c += str(a)
    print(c)

matrix = []
output = [[0 for i in range(3)] for j in range(3)]
for i in range(3):
    matrix.append([int(j) for j in input().split()])
for i in range(3):
    for j in range(3):
        s = 0
        s+=matrix[i][j]
        if i>0:
            s+=matrix[i-1][j]
        if i<2:
            s+=matrix[i+1][j]
        if j>0:
            s+=matrix[i][j-1]
        if j<2:
            s+=matrix[i][j+1]
        output[i][j] = str((s%2+1)%2)
for i in range(3):
    print(''.join(output[i]))

#!/usr/bin/env python

row1 = [int(x) for x in raw_input().split()]
row2 = [int(x) for x in raw_input().split()]
row3 = [int(x) for x in raw_input().split()]

matrix = [row1, row2, row3]

ans = [[1,1,1],[1,1,1],[1,1,1]]

for i in xrange(3):
	for z in xrange(3):
		if matrix[i][z] != 0:
				# print ans
				if i == 0 and z == 0:

					ans[i][z + 1] += matrix[i][z]
					ans[i+1][z] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 0 and z == 1:

					ans[i][z + 1] += matrix[i][z]
					ans[i+1][z] += matrix[i][z]
					ans[i][z - 1] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 0 and z == 2:
					ans[i+1][z] += matrix[i][z]
					ans[i][z - 1] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 1 and z == 0:
					# print "A",ans[i][z]
					# print ans

					ans[i][z + 1] += matrix[i][z]
					ans[i+1][z] += matrix[i][z]
					ans[i-1][z] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 1 and z == 1:

					ans[i][z + 1] += matrix[i][z]
					ans[i+1][z] += matrix[i][z]
					ans[i][z - 1] += matrix[i][z]
					ans[i-1][z] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 1 and z == 2:

					ans[i-1][z] += matrix[i][z]
					ans[i+1][z] += matrix[i][z]
					ans[i][z - 1] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 2 and z == 0:

					ans[i][z + 1] += matrix[i][z]
					ans[i-1][z] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 2 and z == 1:

					ans[i][z + 1] += matrix[i][z]
					ans[i-1][z] += matrix[i][z]
					ans[i][z - 1] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 2 and z == 2:

					ans[i-1][z] += matrix[i][z]
					ans[i][z - 1] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				# print ans
				# print "/",i,z,matrix[i][z]

for i in xrange(3):
	for z in xrange(3):
		if ans[i][z]%2 != 0:
			ans[i][z] = 1
		else:
			ans[i][z] = 0
for r in ans:
	print "".join([str(x) for x in r])

n = [map(int,raw_input().split())for s in range(3)]
a = [[1,1,1],[1,1,1],[1,1,1]]
for i in range(3):
    for j in range(3):
        n[i][j] = n[i][j]%2
for i in range(3):
    for j in range(3):
        if n[i][j]:
            for x in range(i-1,i+2):
                if 0<=x<=2:
                    if a[x][j] ==1:
                        a[x][j] = 0
                    else:
                        a[x][j] = 1
            for y in (j-1,j+1):
                if 0<=y<=2:
                    if a[i][y] == 1:
                        a[i][y] = 0
                    else:
                        a[i][y] = 1
for i in range(3):
    print "".join(map(str,[a[i][j] for j in range(3)]))

#!/usr/bin/env python
# coding: utf-8

# In[104]:

# n = int(input())
# line = list(map(int, input().split()))
line = []
for _ in range(3):
    line.append(list(map(int, input().split())))

# In[109]:

mod_func = lambda x: [[i%2 for i in y] for y in x]
line = mod_func(line)
res = [[1 for _ in range(3)] for _ in range(3)]

for i in range(len(line)):
    for j in range(len(line[i])):
        if line[i][j] == 1:
            res[i][j] = 1 if res[i][j] == 0 else 0
            try:
                res[i][j+1] = 1 if res[i][j+1] == 0 else 0
            except: None
            try:
                if j - 1 >= 0:
                    res[i][j-1] = 1 if res[i][j-1] == 0 else 0
            except: None
            try:
                res[i+1][j] = 1 if res[i+1][j] == 0 else 0
            except: None
            try:
                if i - 1 >= 0:
                    res[i-1][j] = 1 if res[i-1][j] == 0 else 0
            except: None

for i in range(len(res)):
    print("".join(map(str, res[i])))

a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
for i in range(3):
    ans = ""
    for j in range(3):
        s = 0
        s+=a[i][j]
        if i+1<3:
            s+=a[i+1][j]
        if i-1>=0:
            s+=a[i-1][j]
        if j+1<3:
            s+=a[i][j+1]
        if j-1>=0:
            s+=a[i][j-1]
        # print(s,end=" ")
        if s%2==0:
            ans+="1"
        else:
            ans+="0"
    # print()
    print(ans)

#Lights Out
#Problem Link : http://codeforces.com/problemset/problem/275/A

res = list()
res.append([0 , 0 , 0 , 0 , 0])

for i in range(1 , 4):
    res.append([0 , 0 , 0 , 0 , 0])
    res[i][1] , res[i][2] , res[i][3] = map(int , input().split())
res.append([0 , 0 , 0 , 0 , 0])

for i in range(1 , 4):
    for j in range(1 , 4):
        print(1 - (res[i][j] + res[i-1][j] + res[i][j-1] + res[i+1][j] + res[i][j+1])%2 , end='')
    print()

light_turners = list()
light_turners.append([int(x) for x in input().split(" ")])
light_turners.append([int(x) for x in input().split(" ")])
light_turners.append([int(x) for x in input().split(" ")])

lights = [[True, True, True], [True, True, True], [True, True, True]]

def flip_adjacent(i, j):
    lights[i][j] = not lights[i][j]

    if i + 1 < 3:
        lights[i + 1][j] = not lights[i + 1][j]

    if j + 1 < 3:
        lights[i][j + 1] = not lights[i][j + 1]

    if i - 1 > -1:
        lights[i - 1][j] = not lights[i - 1][j]

    if j - 1 > - 1:
        lights[i][j - 1] = not lights[i][j - 1]

for i in range(3):
    for j in range(3):
        while light_turners[i][j] > 0:
            flip_adjacent(i, j)
            light_turners[i][j] -= 1

for i in range(3):
    for j in range(3):
        print(1 if lights[i][j] else 0, end='')
    print('')
# 1476521911520

def main():
    def get_elements(x, y):
        ele = [[x,y]]
        if x==0:
            ele.append([1,y])
        if x==1:
            ele.append([0,y])
            ele.append([2,y])
        if x==2:
            ele.append([1,y])
        if y==0:
            ele.append([x,1])
        if y==1:
            ele.append([x,0])
            ele.append([x,2])
        if y==2:
            ele.append([x,1])
        return ele
    arr = [map(int, raw_input().split()) for i in xrange(3)]
    lights = [[1]*3 for i in xrange(3)]
    for i,k in enumerate(arr):
        for j,l in enumerate(k):
            if l%2==1:
                ele = get_elements(i,j)
                for m in ele:
                    if lights[m[0]][m[1]]==0:
                        lights[m[0]][m[1]] = 1
                    else:
                        lights[m[0]][m[1]] = 0
    for i in xrange(3):
        print ''.join(map(str, lights[i]))
main()

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

String =[[0 for i in range(5)] for j in range(5)]
for i in range(1,4): String[i][1:4] = [int(x)%2 for x in input().split()]
for i in range(1,4):
    for j in range(1,4): print((1+String[i][j] + String[i-1][j]+String[i+1][j]+String[i][j-1]+String[i][j+1])%2, end='')
    print()

l=[map(int,raw_input().split()) for i in xrange(3)]
r=[[1]*3 for i in xrange(3)]
for i in xrange(3):
    for j in xrange(3):
        if not l[i][j]%2: continue
        for (dx,dy) in ((0,0),(0,1),(0,-1),(1,0),(-1,0)):
            if 0 <= i + dx < 3 and 0 <= j + dy < 3 :
                r[i + dx][j + dy] = 1 - r[i + dx][j + dy]

for i in r:
    print ''.join(str(j) for j in i)

sw = list()
for i in range(3):
    lst = list(map(int,input().split()))
    sw.append(lst)
light = [[1,1,1],[1,1,1],[1,1,1]]
for i in range(3):
    for j in range(3):
        while(sw[i][j] > 0):
            if i > 0:
                if(light[i-1][j] == 1):
                    light[i-1][j] = 0
                else:
                    light[i-1][j] = 1
            if i+1 < 3:
                if(light[i+1][j] == 1):
                    light[i+1][j] = 0
                else:
                    light[i+1][j] = 1
            if j > 0:
                if(light[i][j-1] == 1):
                    light[i][j-1] = 0
                else:
                    light[i][j-1] = 1
            if j+1 < 3:
                if(light[i][j+1] == 1):
                    light[i][j+1] = 0
                else:
                    light[i][j+1] = 1
            if(light[i][j] == 1):
                    light[i][j] = 0
            else:
                    light[i][j] = 1
            sw[i][j] -= 1
for i in light:
    for j in i:
        print(j,end='')
    print('')

def change(arr, i, j):
	if arr[i][j] == 0:
		arr[i][j] = 1
	else:
		arr[i][j] = 0
	return arr

lights = [[1, 1, 1, 1, 1] for j in range(5)]
arr = [[int(j) for j in input().split()] for x in range(3)]

for i in range(3):
	for j in range(3):
		num = arr[i][j]	% 2
		while num != 0:
			lights = change(lights, i+1, j+1)
			lights = change(lights, i, j+1)
			lights = change(lights, i+2, j+1)
			lights = change(lights, i+1, j)
			lights = change(lights, i+1, j+2)
			num -= 1

for x in range(1, 4):
	for y in range(1, 4):
		print(lights[x][y], end = '')
	print('')

l = []
m = []

for x in range(0, 3) :

    l.append(map(int, raw_input().split()))

for x in range(0, 3) :

    for y in range(0, 3) :

        count = 0

        for p in range(0, 3) :

            for q in range(0, 3) :

                if ( x==p and abs(y-q)<=1 ) or ( y==q and abs(x-p)<=1 ) :

                    count = count + l[p][q]

        if count % 2 == 0 :

            m.append('1')

        else :

            m.append('0')

print ''.join(m[:3]),"\n",''.join(m[3:6]),"\n",''.join(m[6:])

inp = []
res = []
for i in xrange(0, 3):
	inp.append(raw_input().split())
for i in xrange(0, 3):
	tmp = ""
	for j in xrange(0, 3):
		switches = 0
		for k in xrange(max(0, i - 1), min(3, i + 2)):
			switches += int(inp[k][j])
		for l in xrange(max(0, j - 1), min(3, j + 2)):
			switches += int(inp[i][l])
		switches -= int(inp[i][j])
		#print switches
		tmp += str((switches + 1) % 2)
	res.append(tmp)
for s in res:
	print s

matrix1 = [[-1 for x in range(5)] for y in range(5)]
for i in range(1,4):
    for j in range(1,4):
        matrix1[i][j] = 1

scan = [[-1 for x in range(3)] for y in range(3)]
for i in range(3):
        x = [int(x) for x in input().split()]
        for j in range(len(x)):
            if x[j] % 2 == 1:
                if matrix1[i+1][j+1] == 0:
                    matrix1[i+1][j+1] = 1
                elif matrix1[i+1][j+1] == 1:
                    matrix1[i+1][j+1] = 0
                if matrix1[i + 1][j] == 0:
                    matrix1[i + 1][j] = 1
                elif matrix1[i + 1][j] == 1:
                    matrix1[i + 1][j] = 0
                if matrix1[i][j + 1] == 0:
                    matrix1[i][j + 1] = 1
                elif matrix1[i][j + 1] == 1:
                    matrix1[i][j + 1] = 0
                if matrix1[i + 1][j + 2] == 0:
                    matrix1[i + 1][j + 2] = 1
                elif matrix1[i + 1][j + 2] == 1:
                    matrix1[i + 1][j + 2] = 0
                if matrix1[i + 2][j + 1] == 0:
                    matrix1[i + 2][j + 1] = 1
                elif matrix1[i + 2][j + 1] == 1:
                    matrix1[i + 2][j + 1] = 0

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

b =[[0 for i in range(5)] for j in range(5)]
for i in range(1,4):
    b[i][1:4] = [int(x)%2 for x in input().split()]
for i in range(1,4):
    for j in range(1,4):
        print((1+b[i][j] + b[i-1][j]+b[i+1][j]+b[i][j-1]+b[i][j+1])%2, end='')
    print()

l = [[0 for i in range(5)] for j in range(5)]

for i in range(1,4):
    l[i][1:4]=[int(j) for j in input().split()]

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

def readarray(f): return map(f, raw_input().split())
def readint(): return int(raw_input())
def printlist(l): print ' '.join(map(str, l))

G = []
for i in range(3):
  G.append(readarray(int))
res = [[1]*3 for i in range(3)]

for i in range(3):
  for j in range(3):
    if G[i][j]%2 == 1:
      if i > 0:
        res[i-1][j] = 1-res[i-1][j]
      if i < 2:
        res[i+1][j] = 1-res[i+1][j]
      if j > 0:
        res[i][j-1] = 1-res[i][j-1]
      if j < 2:
        res[i][j+1] = 1-res[i][j+1]
      res[i][j] = 1-res[i][j]
for i in range(3):
  print ''.join(map(str, res[i]))

def permitido(l,c):
    return l >= 0 and c >= 0 and l <= 2 and c <= 2
def muda_adjacentes(i,j):
    if grid[i][j] == "0":
        grid[i][j] = "1"
    else:
        grid[i][j] = "0"

    for m in range(4):
        l_destino = i + mv[m]
        c_destino = j + mh[m]

        if permitido(l_destino,c_destino):

            if grid[i + mv[m]][j + mh[m]] == "0":
                grid[i + mv[m]][j + mh[m]] = "1"

            else:
                grid[i + mv[m]][j + mh[m]] = "0"

mv = [1,-1,0,0]
mh = [0,0,1,-1]

apertos = []

for i in range(3):
    a,b,c = map(int,input().split())

    apertos.append([a,b,c])

grid = []
for i in range(3):
    grid.append(list("111"))

for L in range(3):
    for C in range(3):
        if apertos[L][C] != 0:
            if apertos[L][C] % 2 != 0:
                muda_adjacentes(L,C)

for i in range(3):
    linha = ""
    for j in range(3):
        linha += grid[i][j]

    print(linha)

def toggler(i,j,arr):
    if (i-1)>=0:
        arr[i-1][j]=1-arr[i-1][j]
    if (i+1)<3:
        arr[i+1][j]=1-arr[i+1][j]
    if (j - 1) >= 0:
        arr[i][j-1]=1-arr[i][j-1]
    if (j + 1) < 3:
        arr[i][j+1]=1-arr[i][j+1]
ones=[[1,1,1],[1,1,1],[1,1,1]]

arr=[]
for i in range(3):
    arr.append(list(map(int,input().split())))
for i in range(3):
    for j in range(3):
        if arr[i][j]%2!=0:
            ones[i][j]=1-ones[i][j]
            toggler(i,j,ones)
for i in range(3):
    for j in range(3):
        print(ones[i][j],end="")
    print()

a=[[1,1,1],[1,1,1],[1,1,1]]
b=[]
def list_to_str(a):
    y=''
    for i in range(len(a)):y=y+str(a[i])
    return y
for i in range(3):
    c= list(map(int, input().split()))
    b.append(c)
for i in range(3):
    for j in range(3):
        a[i][j]+=b[i][j]
        if j>=1:a[i][j]+=b[i][j-1]
        if i>=1:a[i][j]+=b[i-1][j]
        try:a[i][j]+=b[i+1][j]
        except IndexError:pass
        try:a[i][j]+=b[i][j+1]
        except IndexError:pass
for i in a:
    for j in range(3):
        if i[j]%2==0:i[j]=0
        else:i[j]=1
for i in a:print(list_to_str(i))

grid = []
for i in range(3):
    row = list(map(int,input().split()))
    grid.append(row)
g = [[1]*3 for _ in range(3)]
for i in range(len(grid)):
    for j in range(len(grid[0])):
        if grid[i][j] & 1 :
            if i-1 >= 0:
                g[i-1][j] = 1- g[i-1][j]
            if j -1 >= 0:
                g[i][j-1] = 1- g[i][j-1]
            if i+1 < len(grid):
                g[i+1][j] = 1- g[i+1][j]
            if j + 1 < len(grid[0]):
                g[i][j+1] = 1- g[i][j+1]
            g[i][j] = 1- g[i][j]
for row in g:
    print("".join(map(str,row)))

import math

arr_initial = [[1,1,1],[1,1,1],[1,1,1]]

tries = []

for i in range(3):
    tries.append(list(map(int, input().split())))

rows = len(tries)
cols = len(tries[0])

for i in range(rows):
    for j in range(cols):
        try_val = tries[i][j]

        while(try_val>0):
            arr_initial[i][j] = 1 - arr_initial[i][j]

            if(i+1<=(rows-1)):
                arr_initial[i+1][j] = 1 - arr_initial[i+1][j]

            if(i-1>=0):
                arr_initial[i-1][j] = 1 - arr_initial[i-1][j]

            if(j+1<=(cols-1)):
                arr_initial[i][j+1] = 1 - arr_initial[i][j+1]

            if(j-1>=0):
                arr_initial[i][j-1] = 1 - arr_initial[i][j-1]

            try_val-=1

itr_ct = 1
final_arr = ""

for i in range(rows):
    for j in range(cols):
        final_arr+=str(arr_initial[i][j])

    if(itr_ct>=0):
        final_arr+="\n"

    itr_ct-=1

print(final_arr)

# coding =utf-8
I = lambda:map(int,raw_input().split())
a = []
b = []
x = [1,-1,0,0,0]
y = [0,0,1,-1,0]
for i in range(3):
	a.append(I())
for i in range(3):
	for j in range(3):
		sum =0
		for k in range(5):
			if i+x[k]>=0 and i+x[k]<=2 and j+y[k]>=0 and j+y[k]<=2:
				sum+=a[i+x[k]][j+y[k]]
		b.append((sum+1)%2)
print str(b[0])+str(b[1])+str(b[2])
print str(b[3])+str(b[4])+str(b[5])
print str(b[6])+str(b[7])+str(b[8])

line1 = map(int, raw_input().split())
line2 = map(int, raw_input().split())
line3 = map(int, raw_input().split())

matrix1 = [0, 0, 0]
matrix2 = [0, 0, 0]
matrix3 = [0, 0, 0]

matrix = []
matrix.append(matrix1)
matrix.append(matrix2)
matrix.append(matrix3)

x1 = line1[0] + line1[1] + line2[0]
x2 = line1[0] + line1[1] + line1[2] + line2[1]
x3 = line1[1] + line1[2] + line2[2]
x4 = line2[0] + line2[1] + line1[0] + line3[0]
x5 = line2[0] + line2[1] + line2[2] + line1[1] + line3[1]
x6 = line2[1] + line2[2] + line1[2] + line3[2]
x7 = line3[0] + line3[1] + line2[0]
x8 = line3[0] + line3[1] + line3[2] + line2[1]
x9 = line3[1] + line3[2] + line2[2]
#print x1, x9
if x1 % 2 == 0:
    matrix1[0] = 1
if x2 % 2 == 0:
    matrix1[1] = 1
if x3 % 2 == 0:
    matrix1[2] = 1
if x4 % 2 == 0:
    matrix2[0] = 1
if x5 % 2 == 0:
    matrix2[1] = 1
if x6 % 2 == 0:
    matrix2[2] = 1
if x7 % 2 == 0:
    matrix3[0] = 1
if x8 % 2 == 0:
    matrix3[1] = 1
if x9 % 2 == 0:
    matrix3[2] = 1

print str(matrix1[0]) +  str(matrix1[1]) + str(matrix1[2])
print str(matrix2[0]) + str(matrix2[1]) + str(matrix2[2])
print str(matrix3[0]) + str(matrix3[1]) + str(matrix3[2])

lights=[[1,1,1],[1,1,1],[1,1,1]]
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
given=[]
given.append(a)
given.append(b)
given.append(c)
def change(i,j):
    if(lights[i][j]==1):
        lights[i][j]=0
    else:
        lights[i][j]=1
for i in range(3):
    for j in range(3):
        if(i==0 and j==0):
            if(given[i][j]%2!=0):
                change(i,j)
                change(i+1,j)
                change(i,j+1)
        if(i==0 and j==1):
            if(given[i][j]%2!=0):
                change(i,j)
                change(i+1,j)
                change(i,j-1)
                change(i,j+1)
        if(i==0 and j==2):
            if(given[i][j]%2!=0):
                change(i,j)
                change(i+1,j)
                change(i,j-1)
        if(i==1 and j==0):
            if(given[i][j]%2!=0):
                change(i,j)
                change(i+1,j)
                change(i,j+1)
                change(i-1,j)
        if(i==1 and j==1):
            if(given[i][j]%2!=0):
                change(i,j)
                change(i-1,j)
                change(i+1,j)
                change(i,j-1)
                change(i,j+1)
        if(i==1 and j==2):
            if(given[i][j]%2!=0):
                change(i,j)
                change(i-1,j)
                change(i+1,j)
                change(i,j-1)
        if(i==2 and j==0):
            if(given[i][j]%2!=0):
                change(i,j)
                change(i-1,j)
                change(i,j+1)
        if(i==2 and j==1):
            if(given[i][j]%2!=0):
                change(i,j)
                change(i-1,j)
                change(i,j-1)
                change(i,j+1)
        if(i==2 and j==2):
            if(given[i][j]%2!=0):
                change(i,j)
                change(i-1,j)
                change(i,j-1)
for i in range(len(lights)):
    c=lights[i]
    a=""
    for j in range(len(c)):
        a+=str(c[j])
    print(a)

m,n=[],[]
for i in range(3):
    a=list(map(int,input().split()))
    for j in range(3):
        if a[j]%2==1:
            m.append(i)
            n.append(j)
a=[[0,0,0],[0,0,0],[0,0,0]]
for i,j in zip(m,n):
    a[i][j]+=1
    try:
        a[i+1][j]+=1
    except:
        pass
    try:
        a[i][j+1]+=1
    except:
        pass
    if j-1>=0:
        a[i][j-1]+=1
    if i-1>=0:
        a[i-1][j]+=1
for i in range(3):
    for j in range(3):
        if a[i][j]%2==0:
            print(1,end='')
        else:
            print(0,end='')
    print()

def p(x):
    return int(x)%2
def t(x):
    return '0' if x=='1' else '1'
l=[]
x=[['1']*3 for i in range(3)]
for i in range(3):
    l.append(list(map(p,input().split())))
for i in range(3):
    for j in range(3):
        if l[i][j]:
            x[i][j]=t(x[i][j])
            if i!=0: x[i-1][j]=t(x[i-1][j])
            if j!=0: x[i][j-1]=t(x[i][j-1])
            if i!=2: x[i+1][j]=t(x[i+1][j])
            if j!=2: x[i][j+1]=t(x[i][j+1])
for i in x:
    print("".join(i))

move =[[1,0],[-1,0],[0,-1],[0,1]]
li   = [list(map(int,input().split())) for i in range(3)]
li1  = [[1 for i in range(3)] for j in range(3)]
for i in range(len(li)):
	for j in range(len(li[i])):
		if li[i][j]&1:
			li1[i][j] = 1-li1[i][j]
			for k in range(len(move)):
				x = i + move[k][0]
				y = j + move[k][1]
				if x >= 0 and x <= 2 and y >= 0 and y <= 2:
					li1[x][y] = 1-li1[x][y]

for i in range(3):
	li1[i] = list(map(str,li1[i]))
	s = ''.join(li1[i])
	print(s)

#all around
d=[(0,0),(1,0),(-1,0),(0,1),(0,-1)]
def f(m,i,j):
    ret=0
    for dx,dy in d:
#ignore the out of range
        if i+dx>=0 and i+dx<=2 and j+dy>=0 and j+dy<=2:
            ret+=m[i+dx][j+dy]
    return ret

m=[map(int, raw_input().split()) for _ in xrange(3)]
ans=[[0]*3 for _ in xrange(3)]
for i in xrange(3):
    for j in xrange(3):
        ans[i][j]=(f(m,i,j)+1)%2
for i in xrange(3):
    print ''.join(map(str,ans[i]))

import sys

ctl = [[1 for x in range(3)] for x in range(3)]

for x in range(3):
    li = [int(z) for z in sys.stdin.readline().split()]
    for y in range(3):
        ctl[x][y] = (ctl[x][y] + li[y]) % 2
        if x-1 >= 0:
            ctl[x-1][y] = (ctl[x-1][y] + li[y]) % 2
        if y-1 >= 0:
            ctl[x][y-1] = (ctl[x][y-1] + li[y]) % 2
        if y+1 <= 2:
            ctl[x][y+1] = (ctl[x][y+1] + li[y]) % 2
        if x +1 <= 2:
            ctl[x+1][y] = (ctl[x+1][y] + li[y]) % 2

for x in range(3):
    print ''.join([str(y) for y in ctl[x]])

def toggle(val):
    if val == 1:
        return 0
    else:
        return 1

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

#intialize = [[0 for i in range(3)] for i in range(3)]

curr_state = [[1 for i in range(3)] for i in range(3)]

temp = 0

for i in range(3):
    for j in range(3):
        if timed[i][j] > temp:
            temp = timed[i][j]

for i in range(timed[0][0]):
    curr_state[0][0] = toggle(curr_state[0][0])
    curr_state[0][1] = toggle(curr_state[0][1])
    curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][1] = toggle(curr_state[1][1])

for _ in range(timed[0][1]):
    curr_state[0][1] = toggle(curr_state[0][1])
    curr_state[0][0] = toggle(curr_state[0][0])
    curr_state[0][2] = toggle(curr_state[0][2])
    curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][2] = toggle(curr_state[1][2])

for _ in range(timed[0][2]):
    curr_state[0][2] = toggle(curr_state[0][2])
    curr_state[0][1] = toggle(curr_state[0][1])
    curr_state[1][2] = toggle(curr_state[1][2])
    #curr_state[1][1] = toggle(curr_state[1][1])

for _ in range(timed[1][0]):
    curr_state[1][0] = toggle(curr_state[1][0])
    curr_state[0][0] = toggle(curr_state[0][0])
    curr_state[2][0] = toggle(curr_state[2][0])
    curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[2][1] = toggle(curr_state[2][1])

for _ in range(timed[1][1]):
    curr_state[1][1] = toggle(curr_state[1][1])
    curr_state[0][1] = toggle(curr_state[0][1])
    curr_state[1][0] = toggle(curr_state[1][0])
    curr_state[1][2] = toggle(curr_state[1][2])
    curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[0][0] = toggle(curr_state[0][0])
    #curr_state[0][2] = toggle(curr_state[0][2])
    #curr_state[2][0] = toggle(curr_state[2][0])
    #curr_state[2][2] = toggle(curr_state[2][2])

for _ in range(timed[1][2]):
    curr_state[1][2] = toggle(curr_state[1][2])
    curr_state[0][2] = toggle(curr_state[0][2])
    curr_state[1][1] = toggle(curr_state[1][1])
    curr_state[2][2] = toggle(curr_state[2][2])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[2][1] = toggle(curr_state[2][1])

for _ in range(timed[2][0]):
    curr_state[2][0] = toggle(curr_state[2][0])
    curr_state[1][0] = toggle(curr_state[1][0])
    curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[1][1] = toggle(curr_state[1][1])

for _ in range(timed[2][1]):
    curr_state[2][1] = toggle(curr_state[2][1])
    curr_state[1][1] = toggle(curr_state[1][1])
    curr_state[2][0] = toggle(curr_state[2][0])
    curr_state[2][2] = toggle(curr_state[2][2])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][2] = toggle(curr_state[1][2])

for _ in range(timed[2][2]):
    curr_state[2][2] = toggle(curr_state[2][2])
    curr_state[1][2] = toggle(curr_state[1][2])
    curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[1][1] = toggle(curr_state[1][1])
'''
if (timed[0][0] >= temp and timed[0][0] > 0):
    #print(curr_state[0][1], curr_state[1][0])
    #curr_state[0][0] = toggle(curr_state[0][0])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][1] = toggle(curr_state[1][1])
    sum1 = timed[0][0] + timed[0][1] + timed[1][0] + timed[1][1]
    if sum1 & 1:
        curr_state[0][0] = 1
    else:
        curr_state[0][0] = 0
    #print(curr_state[0][1], curr_state[1][0])
if (timed[0][1] >= temp and timed[0][1] > 0):
    #print("fck")
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[0][0] = toggle(curr_state[0][0])
    #curr_state[0][2] = toggle(curr_state[0][2])
    #curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][2] = toggle(curr_state[1][2])
    sum1 = timed[0][1] + timed[0][0] + timed[0][2] + timed[1][1] + timed[1][0] + timed[1][2]
    if sum1 & 1:
        curr_state[0][1] = 1
    else:
        curr_state[0][1] = 0
if (timed[0][2] >= temp and timed[0][2] > 0):
    #curr_state[0][2] = toggle(curr_state[0][2])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[1][2] = toggle(curr_state[1][2])
    #curr_state[1][1] = toggle(curr_state[1][1])
    sum1 = timed[0][2] + timed[0][1] + timed[1][2] + timed[1][1]
    if sum1 & 1:
        curr_state[0][2] = 1
    else:
        curr_state[0][2] = 0
if (timed[1][0] >= temp and timed[1][0] > 0):
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[0][0] = toggle(curr_state[0][0])
    #curr_state[2][0] = toggle(curr_state[2][0])
    #curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[2][1] = toggle(curr_state[2][1])
    sum1 = timed[1][0] + timed[0][0] + timed[2][0] + timed[1][1] + timed[0][1] + timed[2][1]
    if sum1 & 1:
        curr_state[1][0] = 1
    else:
        curr_state[1][0] = 0
if (timed[1][1] >= temp and timed[1][1] > 0):
    #curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][2] = toggle(curr_state[1][2])
    #curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[0][0] = toggle(curr_state[0][0])
    #curr_state[0][2] = toggle(curr_state[0][2])
    #curr_state[2][0] = toggle(curr_state[2][0])
    #curr_state[2][2] = toggle(curr_state[2][2])
    sum1 = timed[0][0] + timed[0][1] + timed[0][2] + timed[1][0] + timed[1][1] + timed[1][2] + timed[2][0] + timed[2][1] + timed[2][2]
    if sum1 & 1:
        curr_state[1][1] = 1
    else:
        curr_state[1][1] = 0
if (timed[1][2] >= temp and timed[1][2] > 0):
    #curr_state[1][2] = toggle(curr_state[1][2])
    #curr_state[0][2] = toggle(curr_state[0][2])
    #curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[2][2] = toggle(curr_state[2][2])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[2][1] = toggle(curr_state[2][1])
    sum1 = timed[1][2] + timed[0][2] + timed[1][1] + timed[2][2] + timed[0][1] + timed[2][1]
    if sum1 & 1:
        curr_state[1][2] = 1
    else:
        curr_state[1][2] = 0
if (timed[2][0] >= temp and timed[2][0] > 0):
    #curr_state[2][0] = toggle(curr_state[2][0])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[1][1] = toggle(curr_state[1][1])
    sum1 = timed[2][0] + timed[1][0] + timed[2][1] + timed[1][1]
    if sum1 & 1:
        curr_state[2][0] = 1
    else:
        curr_state[2][0] = 0
if (timed[2][1] >= temp and timed[2][1] > 0):
    #curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[2][0] = toggle(curr_state[2][0])
    #curr_state[2][2] = toggle(curr_state[2][2])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][2] = toggle(curr_state[1][2])
    sum1 = timed[2][1] + timed[1][1] + timed[2][0] + timed[2][2] + timed[1][0] + timed[1][2]
    if sum1 & 1:
        curr_state[2][1] = 1
    else:
        curr_state[2][1] = 0
if (timed[2][2] >= temp and timed[2][2] > 0):
    #curr_state[2][2] = toggle(curr_state[2][2])
    #curr_state[1][2] = toggle(curr_state[1][2])
    #curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[1][1] = toggle(curr_state[1][1])
    sum1 = timed[2][2] + timed[1][2] + timed[2][1] + timed[1][1]
    if sum1 & 1:
        curr_state[2][2] = 1
    else:
        curr_state[2][2] = 0
'''
for i in range(3):
    for j in range(3):
        print(curr_state[i][j], end='')
    print()

a = [0]*9

ls = [int(i) for i in input().split(' ')]+[int(i) for i in input().split(' ')]+[int(i) for i in input().split(' ')]
# print(ls)
c = 0
for i in range(3):
  for j in range(3):
    a[c] += ls[c]
    if(i-1 >= 0):
      a[c] += ls[c-3]
    if(i+1 < 3):
      a[c] += ls[c+3]
    if(j-1 >= 0):
      a[c] += ls[c-1]
    if(j+1 < 3):
      a[c] += ls[c+1]
    # print(c, ' ', a[c])
    a[c] = 1 if(a[c] % 2 == 0) else 0
    print(a[c], end = '')
    c+=1
  print()

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

def fn(i,j,x):
        x[i][j]=change(x[i][j])
        if i>0:
            x[i-1][j]=change(x[i-1][j])
        if i<2:
            x[i+1][j]=change(x[i+1][j])
        if j>0:
            x[i][j-1]=change(x[i][j-1])
        if j<2:
            x[i][j+1]=change(x[i][j+1])
        return x

try:
    x=[[1,1,1],[1,1,1],[1,1,1]]
    for i in range(3):
        a=[int(i) for i in input().split()]
        for j in range(3):
            y=x
            if a[j]%2==1:
               fn(i,j,y)

    for i in y:
        print(*i,sep="")

except:
    pass

def main():

    matrix = []
    for _ in range(3):
        x = list(map(int,input().split()))
        matrix.append(x)

    a = [[1,1,1],[1,1,1],[1,1,1]]
    for i in range(3):
        for j in range(3):
            if matrix[i][j] != 0:
                for q in range(matrix[i][j]):
                    a[i][j] = int(not a[i][j])
                    if i + 1 < 3:
                        a[i + 1][j] = int(not a[i + 1][j])
                    elif i + 1 >= 3:
                        pass
                    if i - 1 >= 0:
                        a[i - 1][j] = int(not a[i - 1][j])
                    elif i - 1 < 0:
                        pass
                    if j + 1 < 3:
                        a[i][j + 1] = int(not a[i][j + 1])
                    elif j + 1 >= 3:
                        pass
                    if j - 1 >= 0:
                        a[i][j - 1] = int(not a[i][j - 1])
    for w in range(3):
        print(''.join(map(str,a[w])))

main()

ans = [[True for i in range(3)] for j in range(3)]
ip = []
for i in range(3):
    k = list(map(int, input().split()))
    ip.append(k)
for i in range(3):
    for j in range(3):
        if ip[i][j]%2==0:
            continue
        ans[i][j] =  not ans[i][j]
        if j-1>-1:
            ans[i][j-1] = not ans[i][j-1]
        if j+1<3:
            ans[i][j+1] = not ans[i][j+1]
        if i+1<3:
            ans[i+1][j] = not ans[i+1][j]
        if i-1>-1:
            ans[i-1][j] = not ans[i-1][j]

for i in range(3):
    for j in range(3):
        if ans[i][j]:
            print("1", end="")
        else:
            print("0", end="")
    print()

# Lang: pypy3.6-v7.1.0-win32\pypy3.exe
# Problem Name: LightsOut
# Problem Serial No: 275
# Problem Type: A
# Problem Url: https://codeforces.com/problemset/problem/275/A
# Solution Generated at: 2019-10-19 17:03:55.288149 UTC

i = int
cin = input
le = len

in_mat = [[j for j in list(map(i, cin().split()))] for _ in range(3)]

matrix = [
    [1, 1, 1],
    [1, 1, 1],
    [1, 1, 1]
]

for y in range(3):
    for r in range(3):
        toggle = in_mat[y][r]
        # if odd
        if toggle & 1:
            matrix[y][r] ^= 1

            if y + 1 in range(0, 3):
                matrix[y+1][r] ^= 1
            if y - 1 in range(0, 3):
                matrix[y-1][r] ^= 1

            if r + 1 in range(0, 3):
                matrix[y][r + 1] ^= 1
            if r - 1 in range(0, 3):
                matrix[y][r - 1] ^= 1

for h in ["".join(map(str, k)) for k in matrix]:
    print(h)
# Accepted

import sys

lampen=[]
for n in range (3):
    hulp=[int(x) for x in sys.stdin.readline().split()]
    lampen.append(hulp)

aantal=[[0,0,0],[0,0,0],[0,0,0]]

aantal[0][0]=lampen[0][0]+lampen[0][1]+lampen[1][0]
aantal[0][1]=lampen[0][0]+lampen[0][1]+lampen[0][2]+lampen[1][1]
aantal[0][2]=lampen[0][2]+lampen[0][1]+lampen[1][2]
aantal[1][0]=lampen[0][0]+lampen[1][0]+lampen[2][0]+lampen[1][1]
aantal[1][1]=lampen[1][0]+lampen[1][1]+lampen[1][2]+lampen[0][1]+lampen[2][1]
aantal[1][2]=lampen[0][2]+lampen[1][1]+lampen[1][2]+lampen[2][2]
aantal[2][0]=lampen[1][0]+lampen[2][0]+lampen[2][1]
aantal[2][1]=lampen[2][0]+lampen[2][1]+lampen[2][2]+lampen[1][1]
aantal[2][2]=lampen[1][2]+lampen[2][2]+lampen[2][1]

regel=''
for x in range (3):
    for y in range(3):
        if aantal[x][y]%2==0:
            regel+=('1')
        else:
            regel+=('0')
    print regel
    regel=''

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]]))

import sys
input = sys.stdin.readline
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s-1)]))
def invr():
    return(map(int,input().split()))

rows = []
rows.append(inlt())
rows.append(inlt())
rows.append(inlt())
amount = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for r in range(3):
    for c in range(3):
        cell = rows[r][c]
        amount[r][c] += cell
        if r - 1 >= 0:
            amount[r-1][c] += cell
        if r + 1 < 3:
            amount[r+1][c] += cell
        if c - 1 >= 0:
            amount[r][c - 1] += cell
        if c + 1 < 3:
            amount[r][c + 1] += cell

for row in range(3):
    for column in range(3):
        cell = amount[row][column]
        if cell % 2 == 0:
            amount[row][column] = 1
        else: amount[row][column] = 0
for row in amount:
    for cell in row:
        print(cell, end = "")
    print()

import sys
import collections
from collections import Counter
import itertools
import math
import timeit

#input = sys.stdin.readline

#########################
# imgur.com/Pkt7iIf.png #
#########################

def sieve(n):
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r

def divs(n, start=1):
    divisors = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return divisors

def divn(n, primes):
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t

def flin(d, x, default = -1):
    left = right = -1
    for i in range(len(d)):
        if d[i] == x:
            if left == -1: left = i
            right = i
    if left == -1:
        return (default, default)
    else:
        return (left, right)

def ceil(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def prr(a, sep=' '): print(sep.join(map(str, a)))
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)

d = [[0]*5 for _ in range(5)]
for i in range(3):
    t = li()
    for j in range(3):
        d[i + 1][j + 1] = t[j]

for i in range(1, 4):
    for j in range(1, 4):
        print(1 - (d[i][j] + d[i - 1][j] + d[i + 1][j] + d[i][j - 1] + d[i][j + 1]) % 2, end = '')
    print()

def dfs(grid, x, y):
    if [x, y] == [0, 0]:
        toggle(x+1,y)
        toggle(x,y+1)

    if [x, y] == [0, 1]:
        toggle(x,y-1)
        toggle(x+1,y)
        toggle(x,y+1)

    if [x, y] == [0, 2]:
        toggle(x,y-1)
        toggle(x+1,y)

    if [x, y] == [1, 0]:
        toggle(x-1,y)
        toggle(x+1, y)
        toggle(x, y+1)

    if [x, y] == [1, 1]:
        toggle(x-1, y)
        toggle(x, y-1)
        toggle(x+1, y)
        toggle(x, y+1)

    if [x, y] == [1, 2]:
        toggle(x-1, y)
        toggle(x, y-1)
        toggle(x+1, y)

    if [x, y] == [2, 0]:
        toggle(x-1 , y)
        toggle(x, y+1)

    if [x, y] == [2, 1]:
        toggle(x-1, y)
        toggle(x, y-1)
        toggle(x, y+1)

    if [x, y] == [2, 2]:
        toggle(x-1 , y)
        toggle(x , y-1)

    toggle(x, y)

def toggle(x, y):
    if result[x][y] == 1:
        result[x][y] = 0
    else:
        result[x][y] = 1

grid = []
result = []
for i in range(3):
    grid.append([int(x) for x in input().split()])
    result.append([1 for x in range(3)])

for row in range(3):
    for col in range(3):
        if grid[row][col] == 0:
            continue

        val = grid[row][col]
        if val % 2 == 0:
            continue
        else:
            dfs(grid, row, col)

# print("-----------------------------------------")
for row in range(3):
    for col in range(3):
        print(result[row][col], end="")
    print()

aux, ma = [], []

for i in range(3):
    linha = map(int, raw_input().split())
    ma.append(linha)
    aux.append([0,0,0])

dx = [0,0,1,-1,0]
dy = [1,-1,0,0,0]

for i in range(3):
    for j in range(3):
        for x, y in zip(dx, dy):
            ni = i + x
            nj = j + y
            if(ni >= 0 and ni < 3 and nj >= 0 and nj < 3):
                aux[ni][nj] += ma[i][j]

for linha in aux:
    print ''.join(map(lambda x : str(1-(x % 2)), linha))

l = []
m = []

for x in range(0, 3) :

    l.append(map(int, raw_input().split()))

for x in range(0, 3) :

    for y in range(0, 3) :

        count = 0

        for p in range(0, 3) :

            for q in range(0, 3) :

                if ( x==p and abs(y-q)<=1 ) or ( y==q and abs(x-p)<=1 ) :

                    count = count + l[p][q]

        if count % 2 == 0 :

            m.append('1')

        else :

            m.append('0')

print ''.join(m[:3]),"\n",''.join(m[3:6]),"\n",''.join(m[6:])

def main():
    lights = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]

    for i in xrange(0, 3):
        r = map(int, raw_input().split())
        for j in xrange(0, 3):
            for k in xrange(0, 3):
                for l in xrange(0, 3):
                    if (k == 0 or k == 2) and (l == 0 or l == 2):
                        continue
                    lights[i+k][j+l] += r[j]

    for i in xrange(1, 4):
        for j in xrange(1, 4):
            lights[i][j] = 0 if lights[i][j] & 1 else 1

    for i in xrange(1, 4):
        print ''.join(map(str, lights[i][1:4]))

if __name__ == '__main__':
    main()

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

temp=[[1 for i in range(3)]for j in range(3)]

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

import sys
input=sys.stdin.buffer.readline

arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
arr3=list(map(int,input().split()))
ans=[]
temp=[]
s=arr1[0]+arr1[1]+arr2[0]
temp.append(s)
s=sum(arr1)+arr2[1]
temp.append(s)
s=arr1[1]+arr1[2]+arr2[2]
temp.append(s)
s=arr1[0]+arr2[0]+arr3[0]+arr2[1]
temp.append(s)
s=arr1[1]+sum(arr2)+arr3[1]
temp.append(s)
s=arr1[2]+arr2[2]+arr3[2]+arr2[1]
temp.append(s)
s=arr2[0]+arr3[0]+arr3[1]
temp.append(s)
s=sum(arr3)+arr2[1]
temp.append(s)
s=arr2[2]+arr3[2]+arr3[1]
temp.append(s)
count=0
for i in range(9):
	count+=1
	if temp[i]%2==0:
		print("1",end=' ')
	else:
		print("0",end=' ')
	if count%3==0:
		print()

import copy

m = []
for i in range(3):
	a = list(map(int,input().split()))
	m.append(a)
for i in range(3):
	for j in range(3):
		m[i][j] = m[i][j] % 2
m1 = copy.deepcopy(m)

ind = 0
for i in m:
	if(i[0]==1):
		m1[ind][1]+=1
	if(i[1]==1):
		m1[ind][0]+=1
		m1[ind][2]+=1
	if(i[2]==1):
		m1[ind][1]+=1
	ind+=1
for i in m:
	for j in range(len(i)):
		ind = m.index(i)
		if(ind==0 and i[j]==1):
			m1[ind+1][j]+=1
		if(ind==1 and i[j]==1):
			m1[ind-1][j]+=1
			m1[ind+1][j]+=1
		if(ind==2 and i[j]==1):
			m1[ind-1][j]+=1

for i in range(3):
	for j in range(3):
		m1[i][j] = m1[i][j] % 2
		if(m1[i][j]==1):
			m1[i][j]='0'
		else:
			m1[i][j]='1'

for i in m1:
	st = "".join(i)
	print(st)

A=[]
for i in range(3):
    arr=list(map(int,input().split()))
    A.append(arr)
ans=[]
res=[]
for i in range(3):

    for j in range(3):
        sum=A[i][j]

        if i==0:
            sum+=A[i+1][j]
            if j==0:
                sum+=A[i][j+1]
            elif j==1:
                sum+=A[i][j+1]
                sum+=A[i][j-1]
            else:
                sum+=A[i][j-1]

        elif i==1:
            sum+=A[i-1][j]
            sum+=A[i+1][j]
            if j==0:
                sum+=A[i][j+1]
            elif j==1:
                sum+=A[i][j-1]
                sum+=A[i][j+1]
            else:
                sum+=A[i][j-1]

        else:
            sum+=A[i-1][j]
            if j==0:
                sum+=A[i][j+1]
            elif j==1:
                sum+=A[i][j+1]
                sum+=A[i][j-1]
            else:
                sum+=A[i][j-1]

        if sum%2==0:
            res.append(1)
        else:
            res.append(0)
        #print(res)
    ans.append(res)
    res=[]
for i in ans:
    print(*i)

M = [[int(i) for i in input().split()] for j in range(3)]

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

res = [[1 for x in range(3)] for y in range(3)]

adj1 = [0, -1, 0, 0, 1]
adj2 = [0, 0, -1, 1, 0]
for i in range(3):
    for j in range(3):
        if M[i][j] == 1:
            for k in range(5):
                adj = [i+adj1[k], j+adj2[k]]
                if adj[0] <= -1 or adj[0] >= 3 or adj[1] <= -1 or adj[1] >= 3: continue
                if res[adj[0]][adj[1]] == 0:
                    res[adj[0]][adj[1]] = 1
                else:
                    res[adj[0]][adj[1]] = 0

print(res)

import sys

lampen=[]
for n in range (3):
    hulp=[int(x) for x in sys.stdin.readline().split()]
    lampen.append(hulp)

aantal=[[0,0,0],[0,0,0],[0,0,0]]

for x in range(3):
    for y in range(3):
        for z in range(3):
            aantal[x][y]+=lampen[x][z]
            aantal[x][y]+=lampen[z][y]
        aantal[x][y]-=lampen[x][y]
print aantal

regel=''
for x in range (3):
    for y in range(3):
        if aantal[x][y]%2==0:
            regel+=('1')
        else:
            regel+=('0')
    print regel
    regel=''

a,b,c=map(int,input().split())
e,f,g=map(int,input().split())
m,n,l=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)

a=[[x&1 for x in map(int,raw_input().split(' '))] for _ in range(3)]
b=[[1,1,1,1,1] for _ in range(5)]
for i in range(3):
     for j in range(3):
          if a[i][j]:
               b[i+1][j+1]=not b[i+1][j+1]
               b[i+2][j+1]=not b[i+2][j+1]
               b[i][j+1]=not b[i][j+1]
               b[i+1][j+2]=not b[i+1][j+2]
               b[i+1][j]=not b[i+1][j]
for i in range(3):
     for j in range(3):
          print int(b[i+1][j+1]),
     print

inputGot = []
for i in range(3):
    got = input().split(" ")
    got = [int(i) for i in got]
    inputGot.append(got)

light = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]

def co_ord(i, j):
    set = []
    for i1 in range(i - 1, i + 2):
        for j1 in range(j - 1, j + 2):
            if 0 <= i1 < 3 and 0 <= j1 < 3:
                set.append((i1, j1))
    if (i == 0 and j == 0) or (i == 0 and j == 2) or (i == 2 and j == 0) or (i ==2 and j == 2):
        set.remove((1, 1))
    if i == 1 and j == 1:
        set.remove((0, 0))
        set.remove((0, 2))
        set.remove((2, 0))
        set.remove((2, 2))
    return set

for i in range(3):
    for j in range(3):
        if(inputGot[i][j] != 0 and inputGot[i][j]%2 != 0):
            # print(inputGot[i][j], " at ", i , ",", j)
            co_ords = co_ord(i, j)
            for i2, j2 in co_ords:
                light[i2][j2] = int(not bool(light[i2][j2]))
            # for element in light:
            #     print(*element, sep='')

for element in light:
    print(*element, sep='')

import sys

lampen=[]
for n in range (3):
    hulp=[int(x) for x in sys.stdin.readline().split()]
    lampen.append(hulp)

aantal=[[0,0,0],[0,0,0],[0,0,0]]

aantal[0][0]=lampen[0][0]+lampen[0][1]+lampen[1][0]
aantal[0][1]=lampen[0][0]+lampen[0][1]+lampen[0][2]+lampen[1][1]
aantal[0][2]=lampen[0][2]+lampen[0][1]+lampen[1][2]
aantal[1][0]=lampen[0][0]+lampen[1][0]+lampen[2][0]+lampen[1][1]
aantal[1][1]=lampen[1][0]+lampen[1][1]+lampen[1][1]+lampen[0][1]+lampen[2][1]
aantal[1][2]=lampen[0][2]+lampen[1][1]+lampen[1][2]+lampen[2][2]
aantal[2][0]=lampen[1][0]+lampen[2][0]+lampen[2][1]
aantal[2][1]=lampen[2][0]+lampen[2][1]+lampen[2][2]+lampen[1][1]
aantal[2][2]=lampen[1][2]+lampen[2][2]+lampen[2][1]

regel=''
for x in range (3):
    for y in range(3):
        if aantal[x][y]%2==0:
            regel+=('1')
        else:
            regel+=('0')
    print regel
    regel=''

# import sys
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

matrix = []

def toggle(key):
    if key == 0:
        return 1
    else:
        return 0

for _ in range(3):
    row = list(map(int, input().split(" ")))
    matrix.append(row)

cpy_matrix = [[ 1 for i in range(3) ] for j in range(3) ]

for i in range(3):
    for j in range(3):
        ways = [
            [i+1, j],
            [i-1, j],
            [i, j+1],
            [i, j-1],
            [i+1, j+1],
            [i+1, j-1],
            [i-1, j+1],
            [i-1, j-1],
        ]

        if matrix[i][j]%2 != 0:
            for key, value in ways:
                if 0<= key < 3 and 0 <= value < 3:
                    cpy_matrix[key][value] = toggle(cpy_matrix[key][value])
            cpy_matrix[i][j] = toggle(cpy_matrix[i][j])

for i in range(3):
    for j in range(3):
        print(cpy_matrix[i][j],end='')
    print()

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:
            for u in range(i, i + 3):
                for v in range(j, j + 3):
                    p[u][v] += 1
for i in range(1, 4):
    print(''.join(str(p[i][j] % 2) for j in range(1, 4)))

def tog(ans,i,j):
    if ans[i][j]=='n':
        ans[i][j]=0     #OFF
    elif ans[i][j]==0:    #OFF
        ans[i][j]=1    #ON
    else:#ON
        ans[i][j]=0

l = []
for i in range(3):
    row = list(map(int,input().split()))
    for j in range(3):
        if row[j]%2==0:
            row[j]=0
        else:
            row[j]=1
    l.append(row)
ans = [['n','n','n'] for i in range(3) ]
for i in range(3):
    for j in range(3):
        if l[i][j]==1:
            tog(ans,i,j)
            if (i+1)<3:
                tog(ans,i+1,j)
                #print(ans[i][j])
            if (i-1)>-1:
                tog(ans,i-1,j)
            if (j+1)<3:
                tog(ans,i,j+1)
            if (j-1)>-1:
                tog(ans,i,j-1)
        else:
            if ans[i][j]=='n':
                ans[i][j]=1
for row in ans:
    print(*row)

m = [list(map(int, input().split())) for i in range(3)]
res = [[1 for j in range(3)] for i in range(3)]

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

for i in range(3):
    for j in range(3):
        if m[i][j] % 2:
            res[i][j] = (res[i][j] + 1) % 2
            for x, y in d:
                dx = i + x
                dy = j + y
                if dx >= 0 and dx < 3 and dy >= 0 and dy < 3:
                    res[dx][dy] = (res[dx][dy] + 1) % 2
for row in res:
    row_str = map(str, row)
    print(" ".join(row_str))

mat=[]
for i in range(3):
    mat.append(list(map(int,input().rstrip().split())))
temp=[[1 for i in range(3)]for j in range(3)]

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

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

def fn(i,j,x):
        x[i][j]=change(x[i][j])
        if i>0:
            x[i-1][j]=change(x[i-1][j])
        if i<2:
            x[i+1][j]=change(x[i+1][j])
        if j>0:
            x[i][j-1]=change(x[i][j-1])
        if j<2:
            x[i][j+1]=change(x[i][j+1])
        return x

try:
    x=[[1,1,1],[1,1,1],[1,1,1]]
    for i in range(3):
        a=[int(i) for i in input().split()]
        for j in range(3):
            if a[j]%2==1:
                y=x
                fn(i,j,y)

    for i in y:
        print(*i,sep="")

except:
    pass

#!/usr/bin/env python
# coding: utf-8

# In[72]:

# n = int(input())
# line = list(map(int, input().split()))
line = []
for _ in range(3):
    line.append(list(map(int, input().split())))

# In[73]:

mod_func = lambda x: [[i%2 for i in y] for y in x]
line = mod_func(line)
res = [[1 for _ in range(3)] for _ in range(3)]

for i in range(len(line)):
    for j in range(len(line[i])):
        if line[i][j] == 1:
            res[i][j] = 0 if res[i][j] == 0 else 0
            try: res[i][j+1] = 1 if res[i][j+1] == 0 else 0
            except: None
            try:
                if j - 1 > 0:
                    res[i][j-1] = 1 if res[i][j-1] == 0 else 0
            except: None
            try: res[i+1][j] = 1 if res[i+1][j] == 0 else 0
            except: None
            try:
                if i - 1 > 0:
                    res[i-1][j] = 1 if res[i-1][j] == 0 else 0
            except: None

print(res)

# In[ ]:

# In[ ]:

matrix = [
    [1,1,1],
    [1,1,1],
    [1,1,1]
]

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

for  row in range(3):
    for col in range(3):
        if inp[row][col] % 2 == 0:
            continue
        else:
            if row > 0:
                matrix[row-1][col] *= -1
            if row < 2:
                matrix[row+1][col] *= -1
            if col < 2:
                matrix[row][col+1] *= -1
            if col > 0:
                matrix[row][col-1] *= -1
            matrix[row][col] *= -1

for  row in matrix:
    res = [ 1 if i > 0 else 0 for i in row]
    print(' '.join(map(str,res)))

lights = []

for i in range(3):
  lights += list(map(int, input().split()))
is_on = [1]*9

neighbors = [[1,3],[0,2,4],[1,5],[0,4,6],[1,3,5,7],[2,4,8],[3,7],[4,6,8],[5,7]]

for i in range(9):
  is_on[i] += lights[i]
  for n in neighbors[i]:
    is_on[i] += lights[n]
  is_on[i] %= 2
  is_on[i] = str(is_on[i])
for i in range(3):
  print(''.join(is_on[i:i+3]))

def toggle(val):
    if val == 1:
        return 0
    else:
        return 1

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

#intialize = [[0 for i in range(3)] for i in range(3)]

curr_state = [[1 for i in range(3)] for i in range(3)]

temp = 0

for i in range(3):
    for j in range(3):
        if timed[i][j] > temp:
            temp = timed[i][j]

for i in range(timed[0][0]):
    curr_state[0][0] = toggle(curr_state[0][0])
    curr_state[0][1] = toggle(curr_state[0][1])
    curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][1] = toggle(curr_state[1][1])

for _ in range(timed[0][1]):
    curr_state[0][1] = toggle(curr_state[0][1])
    curr_state[0][0] = toggle(curr_state[0][0])
    curr_state[0][2] = toggle(curr_state[0][2])
    curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][2] = toggle(curr_state[1][2])

for _ in range(timed[0][2]):
    curr_state[0][2] = toggle(curr_state[0][2])
    curr_state[0][1] = toggle(curr_state[0][1])
    curr_state[1][2] = toggle(curr_state[1][2])
    #curr_state[1][1] = toggle(curr_state[1][1])

for _ in range(timed[1][0]):
    curr_state[1][0] = toggle(curr_state[1][0])
    curr_state[0][0] = toggle(curr_state[0][0])
    curr_state[2][0] = toggle(curr_state[2][0])
    curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[2][1] = toggle(curr_state[2][1])

for _ in range(timed[1][1]):
    curr_state[1][1] = toggle(curr_state[1][1])
    curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[1][0] = toggle(curr_state[1][0])
    curr_state[1][2] = toggle(curr_state[1][2])
    curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[0][0] = toggle(curr_state[0][0])
    curr_state[0][2] = toggle(curr_state[0][2])
    #curr_state[2][0] = toggle(curr_state[2][0])
    #curr_state[2][2] = toggle(curr_state[2][2])

for _ in range(timed[1][2]):
    curr_state[1][2] = toggle(curr_state[1][2])
    curr_state[0][2] = toggle(curr_state[0][2])
    curr_state[1][1] = toggle(curr_state[1][1])
    curr_state[2][2] = toggle(curr_state[2][2])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[2][1] = toggle(curr_state[2][1])

for _ in range(timed[2][0]):
    curr_state[2][0] = toggle(curr_state[2][0])
    curr_state[1][0] = toggle(curr_state[1][0])
    curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[1][1] = toggle(curr_state[1][1])

for _ in range(timed[2][1]):
    curr_state[2][1] = toggle(curr_state[2][1])
    curr_state[1][1] = toggle(curr_state[1][1])
    curr_state[2][0] = toggle(curr_state[2][0])
    curr_state[2][2] = toggle(curr_state[2][2])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][2] = toggle(curr_state[1][2])

for _ in range(timed[2][2]):
    curr_state[2][2] = toggle(curr_state[2][2])
    curr_state[1][2] = toggle(curr_state[1][2])
    curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[1][1] = toggle(curr_state[1][1])
'''
if (timed[0][0] >= temp and timed[0][0] > 0):
    #print(curr_state[0][1], curr_state[1][0])
    #curr_state[0][0] = toggle(curr_state[0][0])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][1] = toggle(curr_state[1][1])
    sum1 = timed[0][0] + timed[0][1] + timed[1][0] + timed[1][1]
    if sum1 & 1:
        curr_state[0][0] = 1
    else:
        curr_state[0][0] = 0
    #print(curr_state[0][1], curr_state[1][0])
if (timed[0][1] >= temp and timed[0][1] > 0):
    #print("fck")
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[0][0] = toggle(curr_state[0][0])
    #curr_state[0][2] = toggle(curr_state[0][2])
    #curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][2] = toggle(curr_state[1][2])
    sum1 = timed[0][1] + timed[0][0] + timed[0][2] + timed[1][1] + timed[1][0] + timed[1][2]
    if sum1 & 1:
        curr_state[0][1] = 1
    else:
        curr_state[0][1] = 0
if (timed[0][2] >= temp and timed[0][2] > 0):
    #curr_state[0][2] = toggle(curr_state[0][2])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[1][2] = toggle(curr_state[1][2])
    #curr_state[1][1] = toggle(curr_state[1][1])
    sum1 = timed[0][2] + timed[0][1] + timed[1][2] + timed[1][1]
    if sum1 & 1:
        curr_state[0][2] = 1
    else:
        curr_state[0][2] = 0
if (timed[1][0] >= temp and timed[1][0] > 0):
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[0][0] = toggle(curr_state[0][0])
    #curr_state[2][0] = toggle(curr_state[2][0])
    #curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[2][1] = toggle(curr_state[2][1])
    sum1 = timed[1][0] + timed[0][0] + timed[2][0] + timed[1][1] + timed[0][1] + timed[2][1]
    if sum1 & 1:
        curr_state[1][0] = 1
    else:
        curr_state[1][0] = 0
if (timed[1][1] >= temp and timed[1][1] > 0):
    #curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][2] = toggle(curr_state[1][2])
    #curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[0][0] = toggle(curr_state[0][0])
    #curr_state[0][2] = toggle(curr_state[0][2])
    #curr_state[2][0] = toggle(curr_state[2][0])
    #curr_state[2][2] = toggle(curr_state[2][2])
    sum1 = timed[0][0] + timed[0][1] + timed[0][2] + timed[1][0] + timed[1][1] + timed[1][2] + timed[2][0] + timed[2][1] + timed[2][2]
    if sum1 & 1:
        curr_state[1][1] = 1
    else:
        curr_state[1][1] = 0
if (timed[1][2] >= temp and timed[1][2] > 0):
    #curr_state[1][2] = toggle(curr_state[1][2])
    #curr_state[0][2] = toggle(curr_state[0][2])
    #curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[2][2] = toggle(curr_state[2][2])
    #curr_state[0][1] = toggle(curr_state[0][1])
    #curr_state[2][1] = toggle(curr_state[2][1])
    sum1 = timed[1][2] + timed[0][2] + timed[1][1] + timed[2][2] + timed[0][1] + timed[2][1]
    if sum1 & 1:
        curr_state[1][2] = 1
    else:
        curr_state[1][2] = 0
if (timed[2][0] >= temp and timed[2][0] > 0):
    #curr_state[2][0] = toggle(curr_state[2][0])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[1][1] = toggle(curr_state[1][1])
    sum1 = timed[2][0] + timed[1][0] + timed[2][1] + timed[1][1]
    if sum1 & 1:
        curr_state[2][0] = 1
    else:
        curr_state[2][0] = 0
if (timed[2][1] >= temp and timed[2][1] > 0):
    #curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[1][1] = toggle(curr_state[1][1])
    #curr_state[2][0] = toggle(curr_state[2][0])
    #curr_state[2][2] = toggle(curr_state[2][2])
    #curr_state[1][0] = toggle(curr_state[1][0])
    #curr_state[1][2] = toggle(curr_state[1][2])
    sum1 = timed[2][1] + timed[1][1] + timed[2][0] + timed[2][2] + timed[1][0] + timed[1][2]
    if sum1 & 1:
        curr_state[2][1] = 1
    else:
        curr_state[2][1] = 0
if (timed[2][2] >= temp and timed[2][2] > 0):
    #curr_state[2][2] = toggle(curr_state[2][2])
    #curr_state[1][2] = toggle(curr_state[1][2])
    #curr_state[2][1] = toggle(curr_state[2][1])
    #curr_state[1][1] = toggle(curr_state[1][1])
    sum1 = timed[2][2] + timed[1][2] + timed[2][1] + timed[1][1]
    if sum1 & 1:
        curr_state[2][2] = 1
    else:
        curr_state[2][2] = 0
'''
for i in range(3):
    for j in range(3):
        print(curr_state[i][j], end='')
    print()

def toggler(i,j,arr):
    if (i-1)>=0:
        arr[i-1][j]=1-arr[i-1][j]
    if (i+1)<3:
        arr[i+1][j]=1-arr[i+1][j]
    if (j - 1) >= 0:
        arr[i][j-1]=1-arr[i][j-1]
    if (j + 1) < 3:
        arr[i][j+1]=1-arr[i][j+1]
ones=[[1,1,1],[1,1,1],[1,1,1]]

arr=[]
for i in range(3):
    arr.append(list(map(int,input().split())))
for i in range(3):
    for j in range(3):
        if arr[i][j]%2!=0:
            ones[i][j]=1-ones[i][j]
            toggler(i,j,ones)
print(ones)

import copy

m = []
for i in range(3):
	a = list(map(int,input().split()))
	m.append(a)
for i in range(3):
	for j in range(3):
		m[i][j] = m[i][j] % 2
m1 = copy.deepcopy(m)

for i in m:
	ind = m.index(i)
	if(i[0]==1):
		m1[ind][1]+=1
	if(i[1]==1):
		m1[ind][0]+=1
		m1[ind][2]+=1
	if(i[2]==1):
		m1[ind][1]+=1
for i in m:
	for j in range(len(i)):
		ind = m.index(i)
		if(ind==0 and i[j]==1):
			m1[ind+1][j]+=1
		if(ind==1 and i[j]==1):
			m1[ind-1][j]+=1
			m1[ind+1][j]+=1
		if(ind==2 and i[j]==1):
			m1[ind-1][j]+=1
print(m1)

for i in range(3):
	for j in range(3):
		m1[i][j] = m1[i][j] % 2
		if(m1[i][j]==1):
			m1[i][j]='0'
		else:
			m1[i][j]='1'
print(m1)

for i in m1:
	st = "".join(i)
	print(st)

lights=[]
light=[[1,1,1],[1,1,1],[1,1,1]]
for i in range(3):
    lights.append(map(int,raw_input().split(' ')))
    for j in range(3):
        if lights[i][j]%2==0:
            lights[i][j]=0
        else:
            lights[i][j]=1
            if i>0:
                light[i-1][j]=light[i-1][j]^1
            if i<2:
                light[i+1][j]=light[i+1][j]^1
            if j > 0:
                light[i][j-1]=light[i][j-1]^1
            if j < 2:
                light[i][j+1]=light[i][j+1]^1
            light[i][j] = light[i][j]^1

for i in range(3):
    for j in range(3):
        print light[i][j],
    print ''

def solve(i, j, lights):
    lights[i][j] ^= 1
    pos = [(i+1,j),(i-1,j),(i, j+1),(i,j-1)]
    for val in pos:
        i, j = val
        if 0 <= i < 3 and 0 <=j and j <3:
            lights[i][j] ^= 1

def main():
    m = n = 3
    a = []
    lights = [[1 for x in range(m)] for y in range(n)]
    for i in range(3):
        a.append([int(x) for x in input().split()])
        for j in range(3):
            if a[i][j] % 2:
                solve(i, j, lights)
    print ( lights )

main()

##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.
mat=[[0,0,0,0,0]]
##input
for i in range(3):
    d=[0]
    col = list(map(int,input().split()));
    d.extend(col)
    d.extend([0])
    mat.append(d);
mat.append([0,0,0,0,0])
i=0
out=[[1,1,1],[1,1,1],[1,1,1]];
for n in range(1,4):
    for m in range(1,4):
        ss=0
        su=[]
        for i in range((n-1),(n+2)):
            st=[]
            for j in range(m-1,m+2):
                st.extend([mat[i][j]]);
            su.append(st);
        ss = sum(map(sum,su))
        ss = ss-(su[0][2]+su[2][0]+su[0][0]+su[2][2])
        if (ss%2)==0:
            out[n-1][m-1]=1;
        else:
            out[n-1][m-1]=0
print(out);

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

#l=[list(map(int,input().split())) for i in range(3)]
l1 = [[0 for _ in range(3)] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if j!=2:
            l1[i][j+1]+=l[i][j]
        if j!=0:
            l1[i][j-1]+=l[i][j]
        if i!=0:
            l1[i-1][j]+=l[i][j]
        if i!=2:
            l1[i+1][j]+=l[i][j]
for i in range(3):
    for j in range(3):
        if l1[i][j]&1:
            print(0,end="")
        else:
            print(1,end="")
    print("\n")

def main():
    lights = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]

    for i in xrange(0, 3):
        r = map(int, raw_input().split())
        for j in xrange(0, 3):
            for k in xrange(0, 3):
                for l in xrange(0, 3):
                    lights[i+k][j+l] += r[j]

    for i in xrange(1, 4):
        for j in xrange(1, 4):
            lights[i][j] = 0 if lights[i][j] & 1 else 1

    for i in xrange(1, 4):
        for j in xrange(1, 4):
            print lights[i][j],
        print

if __name__ == '__main__':
    main()

l = [["1" for x in range(3)] for p in range(3)]
i = [[x for x in map(int, input().split())] for t in range(3)]
for indx1,num in enumerate(i):
    for indx2,num1 in enumerate(num):
        if num1 % 2 != 0 and num1 != 0:
            if l[indx1][indx2] == "1":
                l[indx1][indx2] = "O"
            else:
                l[indx1][indx2] = "1"
            if indx2 + 1 in [0,1,2]:
                if l[indx1][indx2 + 1] == "1":
                    l[indx1][indx2 + 1] = "O"
                else:
                    l[indx1][indx2 + 1] = "1"
            if indx2 - 1 in [0,1,2]:
                if l[indx1][indx2 - 1] == "1":
                    l[indx1][indx2 - 1] = "O"
                else:
                    l[indx1][indx2 - 1] = "1"
            if indx1 + 1 in [0,1,2]:
                if l[indx1 + 1][indx2] == "1":
                    l[indx1 + 1][indx2] = "O"
                else:
                    l[indx1 + 1][indx2] = "1"
            if indx1 - 1 in [0,1,2]:
                if l[indx1 - 1][indx2] == "1":
                    l[indx1 - 1][indx2] = "O"
                else:
                    l[indx1 - 1][indx2] = "1"
for t in l:
    for tt in t:
        print(tt,end='')
    print('')

import sys

lampen=[]
for n in range (3):
    hulp=[int(x) for x in sys.stdin.readline().split()]
    lampen.append(hulp)

aantal=[[0,0,0],[0,0,0],[0,0,0]]

for x in range(3):
    for y in range(3):
        for z in range(3):
            aantal[x][y]+=lampen[x][z]
            aantal[x][y]+=lampen[z][y]
        aantal[x][y]-=lampen[x][y]
#print aantal

regel=''
for x in range (3):
    for y in range(3):
        if aantal[x][y]%2==0:
            regel+=('1')
        else:
            regel+=('0')
    print regel
    regel=''

#!/usr/bin/python

from collections import deque

def ir():
    return int(raw_input())

def ia():
    line = raw_input()
    line = line.split()
    return map(int, line)

n = 3
M = []
for i in range(n):
    M.append(map(int, raw_input().split()))

S = [[0 for j in range(n+2)] for i in range(n+2)]

for i in range(n):
    for j in range(n):
        ii = i + 1
        jj = j + 1
        S[ii  ][jj  ] += M[i][j]
        S[ii+1][jj  ] += M[i][j]
        S[ii-1][jj  ] += M[i][j]
        S[ii  ][jj+1] += M[i][j]
        S[ii  ][jj-1] += M[i][j]

for i in range(n):
    for j in range(n):
        ii = i + 1
        jj = j + 1
        print 1 if S[ii][jj] % 2 == 0 else 0,
    print

b =[[0 for i in range(5)] for j in range(5)]
for i in range(1,4):
    b[i][1:4] = [int(x)%2 for x in input().split()]
for i in range(1,4):
    for j in range(1,4):
        print((1+b[i][j] + b[i-1][j]+b[i+1][j]+b[i][j-1]+b[i][j+1])%2, end=' ')
    print()

ans = [[True for i in range(3)] for j in range(3)]
ip = []
for i in range(3):
    k = list(map(int, input().split()))
    ip.append(k)
for i in range(3):
    for j in range(3):
        if ip[i][j]%2==0:
            continue
        ans[i][j] =  not ans[i][j]
        if j-1>-1:
            ans[i][j-1] = not ans[i][j-1]
        if j+1<3:
            ans[i][j+1] = not ans[i][j+1]
        if i+1<3:
            ans[i+1][j] = not ans[i+1][j]
        if i-1>-1:
            ans[i-1][j] = not ans[i-1][j]

for i in range(3):
    for j in range(3):
        if ans[i][j]:
            print("1 ", end="")
        else:
            print("0 ", end="")
    print()

mat=[]
for i in range(3):
    mat.append(list(map(int,input().rstrip().split())))
temp=[[1 for i in range(3)]for j in range(3)]

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

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]]))

list1 = []
a = []
for i in range(5):
    a.append(0)
list1.append(a)
for j in range(1):
    for i in range(3):

        temp = list(map(int,input().split(' ')))
        temp.append(0)
        temp.insert(0,0)
        #print(temp)
        list1.append(temp)
list1.append(a)
final = []

for i in range(1,4):
    for j in range(1,4):
        sum = 0
        sum = list1[i][j] + list1[i + 1][j] + list1[i - 1][j] + list1[i][j + 1] + list1[i][j - 1]
        if sum % 2 == 1:
            tempo = 0
        else:
            tempo = 1
        final.append(tempo)

#print(final)
for i in range(0,9):
    if (i) % 3 == 0:
        print('')
    print(final[i] , end = '')

a=[]
bb=[0]*3
b=[]
for i in range(3):
    l=list(map(int,input().split()))
    a.append(l)
    b.append(bb[:])
for i in range(3):
    for j in range(3):
        for k in range(3):
            b[i][k]+=a[i][j]
            b[k][j]+=a[i][j]
        b[i][j]-=a[i][j]
for i in range(3):
    for j in range(3):
        if b[i][j]%2==0:
            print(1,end=' ')
        else:
            print(0,end=' ')
    print('')

# Description of the problem can be found at http://codeforces.com/problemset/problem/275/A

l_l = list()

d_x = [ 0, -1,  1,  0,  0]
d_y = [-1,  0,  0,  1,  0]

for i in range(3):
    l_l.append(list(map(int, input().split())))

l_c = list(list(1 for _ in range(3)) for _ in range(3))

for i in range(3):
    for j in range(3):
        if l_l[i][j] % 2 == 1:
            for k in range(5):
                x = j + d_x[k]
                y = i + d_y[k]
                if y >= 0 and y < 3 and x >= 0 and x < 3:
                    l_c[y][x] = abs(1 - l_c[y][x])

for l in l_c:
    print(" ".join(str(i) for i in l))

matrix1 = [[-1 for x in range(5)] for y in range(5)]
for i in range(1,4):
    for j in range(1,4):
        matrix1[i][j] = 1

scan = [[-1 for x in range(3)] for y in range(3)]
for i in range(3):
        x = [int(x) for x in input().split()]
        for j in range(len(x)):
            if x[j] % 2 == 1:
                if matrix1[i+1][j+1] == 0:
                    matrix1[i+1][j+1] = 1
                elif matrix1[i+1][j+1] == 1:
                    matrix1[i+1][j+1] = 0
                if matrix1[i + 1][j] == 0:
                    matrix1[i + 1][j] = 1
                elif matrix1[i + 1][j] == 1:
                    matrix1[i + 1][j] = 0
                if matrix1[i][j + 1] == 0:
                    matrix1[i][j + 1] = 1
                elif matrix1[i][j + 1] == 1:
                    matrix1[i][j + 1] = 0
                if matrix1[i + 1][j + 2] == 0:
                    matrix1[i + 1][j + 2] = 1
                elif matrix1[i + 1][j + 2] == 1:
                    matrix1[i + 1][j + 2] = 0
                if matrix1[i + 2][j + 1] == 0:
                    matrix1[i + 2][j + 1] = 1
                elif matrix1[i + 2][j + 1] == 1:
                    matrix1[i + 2][j + 1] = 0

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

#!/usr/bin/env python
# coding: utf-8

# In[84]:

# n = int(input())
# line = list(map(int, input().split()))
line = []
for _ in range(3):
    line.append(list(map(int, input().split())))

# In[98]:

mod_func = lambda x: [[i%2 for i in y] for y in x]
line = mod_func(line)
res = [[1 for _ in range(3)] for _ in range(3)]

for i in range(len(line)):
    for j in range(len(line[i])):
        if line[i][j] == 1:
            res[i][j] = 0 if res[i][j] == 0 else 0
            try:
                res[i][j+1] = 1 if res[i][j+1] == 0 else 0
            except: None
            try:
                if j - 1 > 0:
                    res[i][j-1] = 1 if res[i][j-1] == 0 else 0
            except: None
            try:
                res[i+1][j] = 1 if res[i+1][j] == 0 else 0
            except: None
            try:
                if i - 1 > 0:
                    res[i-1][j] = 1 if res[i-1][j] == 0 else 0
            except: None

for i in range(len(res)):
    print("".join(map(str, res[i])))

import sys
import math
import collections
from collections import deque

#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt', 'w')

from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2**20)

def factors(n):
    return list(set(reduce(list.__add__,
                           ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))

# for _ in range(int(stdin.readline())):
#n = int(stdin.readline())
#n = int(stdin.readline())
#a = list(map(int, stdin.readline().split()))
#n, m = list(map(int, stdin.readline().split()))
#s = str(stdin.readline().strip('\n'))
b = []
a = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for _ in range(3):
    b.append(list(map(int, stdin.readline().split())))
# print(b)
for i in range(3):
    for j in range(3):
        if b[i][j] % 2 == 1:
            #print([i, j])
            a[i][j] = a[i][j] ^ 1
            if j - 1 >= 0:
                a[i][j - 1] = a[i][j - 1] ^ 1
            if j + 1 < 3:
                a[i][j + 1] = a[i][j + 1] ^ 1
            if i + 1 < 3:
                a[i + 1][j] = a[i + 1][j] ^ 1
            if i - 1 >= 0:
                a[i - 1][j] = a[i - 1][j] ^ 1
for r in range(3):
    for c in range(3):
        print(a[r][c], end=' ')
    print('')
print('')

def inverter(e,i):
	virar = []
	for j in range(e-1,e + 2):
		if not (j < 0 or j > 2):
			for k in range(i-1,i+2):
				if not (k < 0 or k > 2):
					virar.append([j,k])

	for h in virar:
		if stats[h[0]][h[1]] == 1:
			stats[h[0]][h[1]] = 0
		else:
			stats[h[0]][h[1]] = 1

def filtro(inte):
	return (int(inte))%2

toogl = []
stats = []
resultado = []

for e in range(3):
	toogl.append(map(filtro,raw_input().split()))
	stats.append([1]*3)
for e in xrange(3):
	for i in xrange(3):
		if toogl[e][i] == 1:
			inverter(e,i)

for e in stats:
	a = ''
	for i in e:
		a += str(i)
	resultado.append(a)

for e in resultado:
	print e

print ['\n'.join([' '.join(map(str,[(sum(a[x/3][x%3] for x in xrange(9) if abs(r-x/3)+abs(c-x%3)<=1)+1)%2 for c in xrange(3)])) for r in xrange(3)]) for a in [[[int(c) for c in raw_input().split()] for i in xrange(3)]]][0]

import math

arr_initial = [[1,1,1],[1,1,1],[1,1,1]]

tries = []

for i in range(3):
    tries.append(list(map(int, input().split())))

rows = len(tries)
cols = len(tries[0])

for i in range(rows):
    for j in range(cols):
        try_val = tries[i][j]

        while(try_val>0):
            arr_initial[i][j] = 1 - arr_initial[i][j]

            if(i+1<=(rows-1)):
                arr_initial[i+1][j] = 1 - arr_initial[i+1][j]

            if(i-1>=0):
                arr_initial[i-1][j] = 1 - arr_initial[i-1][j]

            if(j+1<=(cols-1)):
                arr_initial[i][j+1] = 1 - arr_initial[i][j+1]

            if(j-1>=0):
                arr_initial[i][j-1] = 1 - arr_initial[i][j-1]

            try_val-=1

print(arr_initial)

light_turners = list()
light_turners.append([int(x) for x in input().split(" ")])
light_turners.append([int(x) for x in input().split(" ")])
light_turners.append([int(x) for x in input().split(" ")])

lights = [[True, True, True], [True, True, True], [True, True, True]]

def flip_adjacent(i, j):
    lights[i][j] = not lights[i][j]

    lights[i][0] = not lights[i][0]
    lights[i][1] = not lights[i][1]
    lights[i][2] = not lights[i][2]

    lights[0][j] = not lights[0][j]
    lights[1][j] = not lights[1][j]
    lights[2][j] = not lights[2][j]

for i in range(3):
    for j in range(3):
        while light_turners[i][j] > 0:
            flip_adjacent(i, j)
            light_turners[i][j] -= 1

for i in range(3):
    for j in range(3):
        print(1 if lights[i][j] else 0, end='')
    print('')

#!/usr/bin/env python
# coding: utf-8

# In[72]:

# n = int(input())
# line = list(map(int, input().split()))
line = []
for _ in range(3):
    line.append(list(map(int, input().split())))

# In[83]:

mod_func = lambda x: [[i%2 for i in y] for y in x]
line = mod_func(line)
res = [[1 for _ in range(3)] for _ in range(3)]

for i in range(len(line)):
    for j in range(len(line[i])):
        if line[i][j] == 1:
            res[i][j] = 0 if res[i][j] == 0 else 0
            try: res[i][j+1] = 1 if res[i][j+1] == 0 else 0
            except: None
            try:
                if j - 1 > 0:
                    res[i][j-1] = 1 if res[i][j-1] == 0 else 0
            except: None
            try: res[i+1][j] = 1 if res[i+1][j] == 0 else 0
            except: None
            try:
                if i - 1 > 0:
                    res[i-1][j] = 1 if res[i-1][j] == 0 else 0
            except: None

    print("".join(map(str, res[i])))

##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.
mat=[[0,0,0,0,0]]
##input
for i in range(3):
    d=[0]
    col = list(map(int,input().split()));
    d.extend(col)
    d.extend([0])
    mat.append(d);
mat.append([0,0,0,0,0])
i=0
out=[[1,1,1],[1,1,1],[1,1,1]];
for n in range(1,4):
    for m in range(1,4):
        ss=0
        su=[]
        for i in range((n-1),(n+2)):
            st=[]
            for j in range(m-1,m+2):
                st.extend([mat[i][j]]);
            su.append(st);
        ss = sum(map(sum,su))
        ss = ss-(su[0][2]+su[2][0]+su[0][0]+su[2][2])
        if (ss%2)==0:
            out[n-1][m-1]=1;
        else:
            out[n-1][m-1]=0
i=0;
j=0;
for i in range(3):
    for j in range(3):
        print(out[i][j],end=' ');
    print('');

a=[]
for i in range(3):
    b=[int(x) for x in input().split()]
    a.append(b)
for i in range(3):
    for j in range(3):
        c=0
        if(i!=2):
            c+=a[i+1][j]
        if(j!=2):
            c+=a[i][j+1]
        if(i>0):
            c+=a[i-1][j]
        if(j>0):
            c+=a[i][j-1]
        print((1-(c%2)),end='')
    print()

m,n=[],[]
for i in range(3):
    a=list(map(int,input().split()))
    for j in range(3):
        if a[j]%2==1:
            m.append(i)
            n.append(j)
print(m,n)
a=[[0,0,0],[0,0,0],[0,0,0]]
for i,j in zip(m,n):
    try:
        a[i][j]+=1
        print(a)
    except:
        pass
    try:
        a[i+1][j]+=1
        print(a)
    except:
        pass
    try:
        a[i][j+1]+=1
        print(a)
    except:
        pass
    try:
        a[i+1][j+1]+=1
        print(a)
    except:
        pass
    if i-1>=0:
        try:
            a[i-1][j+1]+=1
            print(a)
        except:
            pass
    if j-1>=0:
        try:
            a[i+1][j-1]+=1
            print(a)
        except:
            pass
    if j-1>=0:
        try:
            a[i][j-1]+=1
            print(a)
        except:
            pass
    if i-1>=0:
        try:
            a[i-1][j]+=1
            print(a)
        except:
            pass
    if i-1>=0 and j-1>=0:
        try:
            a[i-1][j-1]+=1
            print(a)
        except:
            pass
print(a)

light_turners = list()
light_turners.append([int(x) for x in input().split(" ")])
light_turners.append([int(x) for x in input().split(" ")])
light_turners.append([int(x) for x in input().split(" ")])

lights = [[True, True, True], [True, True, True], [True, True, True]]

def flip_adjacent(i, j):
    lights[i][j] = not lights[i][j]

    lights[i][0] = not lights[i][0]
    lights[i][1] = not lights[i][1]
    lights[i][2] = not lights[i][2]

    lights[0][j] = not lights[0][j]
    lights[1][j] = not lights[1][j]
    lights[2][j] = not lights[2][j]

for i in range(3):
    for j in range(3):
        if light_turners[i][j] % 2 == 1:
            flip_adjacent(i, j)

for i in range(3):
    for j in range(3):
        print(1 if lights[i][j] else 0, end='')
    print('')

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:
            for u in range(i, i + 3):
                for v in range(j, j + 3):
                    p[u][v] += 1
for i in range(1, 4):
    print(''.join(str(p[i][j] % 2) for j in range(1, 4)))

def main():
    lights = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]

    for i in xrange(0, 3):
        r = map(int, raw_input().split())
        for j in xrange(0, 3):
            for k in xrange(0, 3):
                for l in xrange(0, 3):
                    lights[i+k][j+l] += r[j]

    for i in xrange(1, 4):
        for j in xrange(1, 4):
            lights[i][j] = 0 if lights[i][j] & 1 else 1

    for i in xrange(1, 4):
        for j in xrange(1, 4):
            print lights[i][j],
        print

if __name__ == '__main__':
    main()

def switcher(string):
    if string == '1':
        return string.replace('1', '0')
    else:
        return string.replace('0', '1')

inicial = [['1', '1', '1'], ['1', '1', '1'], ['1', '1', '1']]
matriz = []
for i in range(3):
    matriz.append(''.join(input().split()))

for i in range(len(matriz)):
    for j in range(len(matriz[i])):
        if int(matriz[i][j]) % 2 != 0:
            if j == 0 and i == 0:
                inicial[i][j] = switcher(inicial[i][j])
                inicial[i][j+1] = switcher(inicial[i][j+1])
                inicial[i+1][j] = switcher(inicial[i+1][j])
            elif j == 1 and i == 0:
                inicial[i][j] = switcher(inicial[i][j])
                inicial[i][j+1] = switcher(inicial[i][j+1])
                inicial[i+1][j] = switcher(inicial[i+1][j])
                inicial[i][j-1] = switcher(inicial[i][j-1])
            elif j == 2 and i == 0:
                inicial[i][j] = switcher(inicial[i][j])
                inicial[i][j-1] = switcher(inicial[i][j-1])
                inicial[i+1][j] = switcher(inicial[i+1][j])
            elif j == 0 and i == 1:
                inicial[i][j] = switcher(inicial[i][j])
                inicial[i][j+1] = switcher(inicial[i][j+1])
                inicial[i+1][j] = switcher(inicial[i+1][j])
                inicial[i-1][j] = switcher(inicial[i-1][j])
            elif j == 1 and i == 1:
                inicial[i][j] = switcher(inicial[i][j])
                inicial[i][j+1] = switcher(inicial[i][j+1])
                inicial[i+1][j] = switcher(inicial[i+1][j])
                inicial[i][j-1] = switcher(inicial[i][j-1])
                inicial[i-1][j] = switcher(inicial[i-1][j])
            elif j == 2 and i == 1:
                inicial[i][j] = switcher(inicial[i][j])
                inicial[i][j-1] = switcher(inicial[i][j-1])
                inicial[i+1][j] = switcher(inicial[i+1][j])
                inicial[i-1][j] = switcher(inicial[i-1][j])
            elif j == 0 and i == 2:
                inicial[i][j] = switcher(inicial[i][j])
                inicial[i][j+1] = switcher(inicial[i][j+1])
                inicial[i-1][j] = switcher(inicial[i-1][j])
            elif j == 1 and i == 2:
                inicial[i][j] = switcher(inicial[i][j])
                inicial[i][j+1] = switcher(inicial[i][j+1])
                inicial[i][j-1] = switcher(inicial[i][j-1])
                inicial[i-1][j] = switcher(inicial[i-1][j])
            elif j == 2 and i == 2:
                inicial[i][j] = switcher(inicial[i][j])
                inicial[i][j-1] = switcher(inicial[i][j-1])
                inicial[i-1][j] = switcher(inicial[i-1][j])

print(''.join(inicial[0]))
print(''.join(inicial[1]))
print(''.join(inicial[2]))

def calc(grid):
    n = [["1" for y in range(3)] for x in range(3)]
    for row in range(len(grid)):
        for col in range(len(grid[0])):
            update(n, grid, row, col)
    return n
def update(n, grid, row, col):
    c = grid[row][col]
    c %=2
    if c != 0:
        # toggle adjacent lights
        for nr, nc in zip([row-1, row+1, row, row], [col, col, col-1,col+1]):
            if nr>=0 and nr<len(n) and nc>=0 and nc<len(n[0]):
                n[nr][nc] = "1" if n[nr][nc] == "0" else "0"
        n[row][col] = "1" if n[row][col] == "0" else "0"

# get inputs
grid = []
for _ in range(3):
    grid.append(list(map(int, input().split())))
n = calc(grid)
for row in n:
    print(' '.join(row))

sw = list()
for i in range(3):
    lst = list(map(int,input().split()))
    sw.append(lst)
light = [[1,1,1],[1,1,1],[1,1,1]]
for i in range(3):
    for j in range(3):
        while(sw[i][j] > 0):
            if i > 0:
                if(light[i-1][j] == 1):
                    light[i-1][j] = 0
                else:
                    light[i-1][j] = 1
            if i+1 < 3:
                if(light[i+1][j] == 1):
                    light[i+1][j] = 0
                else:
                    light[i+1][j] = 1
            if j > 0:
                if(light[i][j-1] == 1):
                    light[i][j-1] = 0
                else:
                    light[i][j-1] = 1
            if j+1 < 3:
                if(light[i][j+1] == 1):
                    light[i][j+1] = 0
                else:
                    light[i][j+1] = 1
            if(light[i][j] == 1):
                    light[i][j] = 0
            else:
                    light[i][j] = 1
            print(light)
            sw[i][j] -= 1
for i in light:
    for j in i:
        print(j,end='')
    print('')

import sys
import math
import collections
from collections import deque

#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt', 'w')

from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2**20)

def factors(n):
    return list(set(reduce(list.__add__,
                           ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))

# for _ in range(int(stdin.readline())):
#n = int(stdin.readline())
#n = int(stdin.readline())
#a = list(map(int, stdin.readline().split()))
#n, m = list(map(int, stdin.readline().split()))
#s = str(stdin.readline().strip('\n'))
b = []
a = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for _ in range(3):
    b.append(list(map(int, stdin.readline().split())))
# print(b)
for i in range(3):
    for j in range(3):
        if b[i][j] % 2 == 1:
            a[i][j] = a[i][j] ^ 1
            if j - 1 >= 0:
                a[i][j - 1] = a[i][j - 1] ^ 1
            if j + 1 < 3:
                a[i][j + 1] = a[i][j + 1] ^ 1

            if i + 1 < 3:
                a[i + 1][j] = a[i + 1][j] ^ 1
                if j - 1 >= 0:
                    a[i + 1][j - 1] = a[i + 1][j - 1] ^ 1
                if j + 1 < 3:
                    a[i + 1][j + 1] = a[i + 1][j + 1] ^ 1
            if i - 1 >= 0:
                a[i - 1][j] = a[i - 1][j] ^ 1
                if j - 1 >= 0:
                    a[i - 1][j - 1] = a[i - 1][j - 1] ^ 1
                if j + 1 < 3:
                    a[i - 1][j + 1] = a[i - 1][j + 1] ^ 1
for i in range(3):
    for j in range(3):
        print(a[i][j], end='')
    print('')

l = [[0 for i in range(5)] for j in range(5)]
print(l)
for i in range(1,4):
    l[i][1:4]=[int(j) for j in input().split()]

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

def toggle(x, y):
	if(ini[x][y] == 1):
		ini[x][y] = 0
	else :
		ini[x][y] = 1

def find_neighbours(x,y):
	toggle(x,y)
	if(x - 1 > 0):
		toggle(x - 1, y)
	if(x + 1 < 3):
		toggle(x + 1, y)
	if(y - 1 > 0):
		toggle(x, y - 1)
	if(y + 1 < 3):
		toggle(x , y + 1)

matrix = []

ini = [[ 1 for i in range(3)] for j in range(3)]

rows = []
for i in range(3):
	rows = map(int, raw_input().split())

	for j in range(len(rows)):
		if rows[j] % 2 == 0:
			rows[j] = 0
		else :
			rows[j] = 1
	matrix.append(rows)

for i in range(3):
	for j in range(3):
		if matrix[i][j] == 1:
			find_neighbours(i, j)

a = ""
for i in range(3):
	a = map(str, ini[i])
	a = ''.join(a)
	print(a)

ans=[[1 for i in range(3)] for j in range(3)]
q=[]
for i in range(3):
	q.append(list(map(int,input().split())))
for i in range(3):
	for j in range(3):
		if(q[i][j]%2==1):
			ans[i][j]=ans[i][j]^1
			if(i-1>=0):
				ans[i-1][j]=ans[i-1][j]^1
			if(i+1<3):
				ans[i+1][j]=ans[i+1][j]^1
			if(j-1>=0):
				ans[i][j-1]=ans[i][j-1]^1
			if(j+1<3):
				ans[i][j+1]=ans[i][j+1]^1

for i in range(3):
	print(*ans[i])

l=lambda:map(int, raw_input().split())
a=[[1,1,1],[1,1,1],[1,1,1]]
m=[l(),l(),l()]

for i in range(3):
    for j in range(3):
        if m[i][j]:

            for k in range(3):

                a[k][j] = 1 - a[k][j]

                if k != j:
                    a[i][k] = 1 - a[i][k]

print '\n'.join(''.join(map(str, e))for e in a)

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

#print(mat)
for i in mat:
    for j in i:
        if j == 0 or j%2 == 0:
            print('1',end='')
        else:
            print('0',end='')
    print()

def test():
    def switch(x, y):
        direct = [[1,0],[0,1],[-1,0],[0,-1]]
        for i in direct:
            new_row = i[0] + x
            new_col = i[1] + y
            if new_row >= 0 and new_col >= 0 and new_row < 3 and new_col < 3:
                lights[new_row][new_col] = 0 if lights[new_row][new_col] == 1 else 1
        lights[x][y] = 0 if lights[x][y] == 1 else 1
    lights = [[1,1,1],[1,1,1],[1,1,1]]
    for i in range(3):
        act = input().split()
        for j in range(3):
            if int(act[j]) % 2 == 1:
                switch(i, j)
    print(lights)

if __name__ == "__main__":
    test()

#!/usr/bin/env python

row1 = [int(x) for x in raw_input().split()]
row2 = [int(x) for x in raw_input().split()]
row3 = [int(x) for x in raw_input().split()]

matrix = [row1, row2, row3]

ans = [[1,1,1],[1,1,1],[1,1,1]]

for i in xrange(3):
	for z in xrange(3):
		if matrix[i][z] != 0:
				# print ans
				if i == 0 and z == 0:

					ans[i][z + 1] += matrix[i][z]
					ans[i+1][z] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 0 and z == 1:

					ans[i][z + 1] += matrix[i][z]
					ans[i+1][z] += matrix[i][z]
					ans[i][z - 1] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 0 and z == 2:
					ans[i+1][z] += matrix[i][z]
					ans[i][z - 1] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 1 and z == 0:
					# print "A",ans[i][z]
					# print ans

					ans[i][z + 1] += matrix[i][z]
					ans[i+1][z] += matrix[i][z]
					ans[i-1][z] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 1 and z == 1:

					ans[i][z + 1] += matrix[i][z]
					ans[i+1][z] += matrix[i][z]
					ans[i][z - 1] += matrix[i][z]
					ans[i-1][z] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 1 and z == 2:

					ans[i-1][z] += matrix[i][z]
					ans[i+1][z] += matrix[i][z]
					ans[i][z - 1] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 2 and z == 0:

					ans[i][z + 1] += matrix[i][z]
					ans[i-1][z] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 2 and z == 1:

					ans[i][z + 1] += matrix[i][z]
					ans[i-1][z] += matrix[i][z]
					ans[i][z - 1] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				elif i == 2 and z == 2:

					ans[i-1][z] += matrix[i][z]
					ans[i][z - 1] += matrix[i][z]
					ans[i][z] += matrix[i][z]
				# print ans
				# print "/",i,z,matrix[i][z]

for i in xrange(3):
	for z in xrange(3):
		if ans[i][z]%2 != 0:
			ans[i][z] = 1
		else:
			ans[i][z] = 0
for r in ans:
	print " ".join([str(x) for x in r])

a=[]
for i in range(3):
    b=[int(x) for x in input().split()]
    a.append(b)
for i in range(3):
    for j in range(3):
        c=0
        if(i!=2):
            c+=a[i+1][j]
        if(j!=2):
            c+=a[i][j+1]
        if(i>0):
            c+=a[i-1][j]
        if(j>0):
            c+=a[i][j-1]
        print((1-(c%2)),end='')
    print()

def toggle(val):
    if val == 1:
        return 0
    else:
        return 1

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

#intialize = [[0 for i in range(3)] for i in range(3)]

curr_state = [[1 for i in range(3)] for i in range(3)]

maxi = 0

for i in range(3):
    for j in range(3):
        if timed[i][j] > maxi:
            maxi = timed[i][j]

#print(maxi)
temp = 0

while(True):
    temp += 1
    if temp > maxi:
        break
    if (timed[0][0] >= temp):
        #print(curr_state[0][1], curr_state[1][0])
        curr_state[0][0] = toggle(curr_state[0][0])
        curr_state[0][1] = toggle(curr_state[0][1])
        curr_state[1][0] = toggle(curr_state[1][0])
        curr_state[1][1] = toggle(curr_state[1][1])
        #print(curr_state[0][1], curr_state[1][0])
    if (timed[0][1] >= temp):
        curr_state[0][1] = toggle(curr_state[0][1])
        curr_state[0][0] = toggle(curr_state[0][0])
        curr_state[0][2] = toggle(curr_state[0][2])
        curr_state[1][1] = toggle(curr_state[1][1])
        curr_state[1][0] = toggle(curr_state[1][0])
        curr_state[1][2] = toggle(curr_state[1][2])
    if (timed[0][2] >= temp):
        curr_state[0][2] = toggle(curr_state[0][2])
        curr_state[0][1] = toggle(curr_state[0][1])
        curr_state[1][2] = toggle(curr_state[1][2])
        curr_state[1][1] = toggle(curr_state[1][1])
    if (timed[1][0] >= temp):
        curr_state[1][0] = toggle(curr_state[1][0])
        curr_state[0][0] = toggle(curr_state[0][0])
        curr_state[2][0] = toggle(curr_state[2][0])
        curr_state[1][1] = toggle(curr_state[1][1])
        curr_state[0][1] = toggle(curr_state[0][1])
        curr_state[2][1] = toggle(curr_state[2][1])
    if (timed[1][1] >= temp):
        curr_state[1][1] = toggle(curr_state[1][1])
        curr_state[0][1] = toggle(curr_state[0][1])
        curr_state[1][0] = toggle(curr_state[1][0])
        curr_state[1][2] = toggle(curr_state[1][2])
        curr_state[2][1] = toggle(curr_state[2][1])
        curr_state[0][0] = toggle(curr_state[0][0])
        curr_state[0][2] = toggle(curr_state[0][2])
        curr_state[2][0] = toggle(curr_state[2][0])
        curr_state[2][2] = toggle(curr_state[2][2])
    if (timed[1][2] >= temp):
        curr_state[1][2] = toggle(curr_state[1][2])
        curr_state[0][2] = toggle(curr_state[0][2])
        curr_state[1][1] = toggle(curr_state[1][1])
        curr_state[2][2] = toggle(curr_state[2][2])
        curr_state[0][1] = toggle(curr_state[0][1])
        curr_state[2][1] = toggle(curr_state[2][1])
    if (timed[2][0] >= temp):
        curr_state[2][0] = toggle(curr_state[2][0])
        curr_state[1][0] = toggle(curr_state[1][0])
        curr_state[2][1] = toggle(curr_state[2][1])
        curr_state[1][1] = toggle(curr_state[1][1])
    if (timed[2][1] >= temp):
        curr_state[2][1] = toggle(curr_state[2][1])
        curr_state[1][1] = toggle(curr_state[1][1])
        curr_state[2][0] = toggle(curr_state[2][0])
        curr_state[2][2] = toggle(curr_state[2][2])
        curr_state[1][0] = toggle(curr_state[1][0])
        curr_state[1][2] = toggle(curr_state[1][2])
    if (timed[2][2] >= temp):
        curr_state[2][2] = toggle(curr_state[2][2])
        curr_state[1][2] = toggle(curr_state[1][2])
        curr_state[2][1] = toggle(curr_state[2][1])
        curr_state[1][1] = toggle(curr_state[1][1])

for i in range(3):
    for j in range(3):
        print(curr_state[i][j], end='')
    print()

A = []
B = []
for i in range(3):
    A += [list(map(int,input().split()))]
    B += [[1] * 3]
for i in range(3):
    for j in range(3):
        if A[i][j] % 2 == 1:
            if i > 0:
                B[i - 1][j] ^= 1
            if i < 2:
                B[i + 1][j] ^= 1
            if j > 0:
                B[i][j-1] ^= 1
            if j < 2:
                B[i][j+1] ^= 1
            B[i][j] ^= 1
for a in B:
    for j in a:
        print(j, end= ' ')
    print()