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

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


-----Input-----

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


-----Output-----

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


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

Output
001
010
100

Input
1 0 1
8 8 8
2 0 3

Output
010
011
100

Source: codeforces | Difficulty: EASY
Tags: Implementation


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


def lights(value):
	if value == 0:
		return 1
	else:
		return 0
matrix = []
for i in range(3):
	matrix.append(list(map(int, input().split())))
ans = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
if matrix[0][0] % 2 != 0:
	ans[0][0] = 0
	ans[0][1] = 0
	ans[1][0] = 0
if matrix[0][1] % 2 != 0:
	ans[0][1] = lights(ans[0][1])
	ans[0][0] = lights(ans[0][0])
	ans[0][2] = lights(ans[0][2])
	ans[1][1] = lights(ans[1][1])
if matrix[0][2] % 2 != 0:
	ans[0][2] = lights(ans[0][2])
	ans[0][1] = lights(ans[0][1])
	ans[1][2] = lights(ans[1][2])
if matrix[1][0] % 2 != 0:
	ans[1][0] = lights(ans[1][0])
	ans[0][0] = lights(ans[0][0])
	ans[2][0] = lights(ans[2][0])
	ans[1][1] = lights(ans[1][1])
if matrix[1][1] % 2 != 0:
	ans[1][1] = lights(ans[1][1])
	ans[0][1] = lights(ans[0][1])
	ans[1][0] = lights(ans[1][0])
	ans[1][2] = lights(ans[1][2])
	ans[2][1] = lights(ans[2][1])
if matrix[1][2] % 2 != 0:
	ans[1][2] = lights(ans[1][2])
	ans[0][2] = lights(ans[0][2])
	ans[1][1] = lights(ans[1][1])
	ans[2][2] = lights(ans[2][2])
if matrix[2][0] % 2 != 0:
	ans[2][0] = lights(ans[2][0])
	ans[1][0] = lights(ans[1][0])
	ans[2][1] = lights(ans[2][1])
if matrix[2][1] % 2 != 0:
	ans[2][1] = lights(ans[2][1])
	ans[2][0] = lights(ans[2][0])
	ans[2][2] = lights(ans[2][2])
	ans[1][1] = lights(ans[1][1])
if matrix[2][2] % 2 != 0:
	ans[2][2] = lights(ans[2][2])
	ans[2][1] = lights(ans[2][1])
	ans[1][2] = lights(ans[1][2])
for i in range(3):
	s = ''
	for j in range(3):
		s += str(ans[i][j])
	print(s)


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


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


def get_side_adjacents(matrix, curr_pos):
	m_length = len(matrix[0]) - 1
	m_height = len(matrix) - 1
	if curr_pos[0] == 0 and curr_pos[1] == 0:
		return [(0, 1), (1, 0)]
	elif curr_pos[0] == 0 and curr_pos[1] == m_length:
		return [(0, m_length - 1), (1, m_length)]
	elif curr_pos[0] == m_height and curr_pos[1] == 0:
		return [(m_height - 1, 0), (m_height, 1)]
	elif curr_pos[0] == m_height and curr_pos[1] == m_length:
		return [(m_height, m_length - 1), (m_height - 1, m_length)]
	elif curr_pos[1] == 0:
		return [(curr_pos[0] - 1, curr_pos[1]), (curr_pos[0] + 1, curr_pos[1]), (curr_pos[0], curr_pos[1] + 1)]
	elif curr_pos[1] == m_length:
		return [(curr_pos[0] + 1, curr_pos[1]), (curr_pos[0] - 1, curr_pos[1]), (curr_pos[0], curr_pos[1] - 1)]
	elif curr_pos[0] == 0:
		return [(curr_pos[0], curr_pos[1] - 1), (curr_pos[0], curr_pos[1] + 1), (curr_pos[0] + 1, curr_pos[1])]
	elif curr_pos[0] == m_height:
		return [(curr_pos[0], curr_pos[1] - 1), (curr_pos[0], curr_pos[1] + 1), (curr_pos[0] - 1, curr_pos[1])]
	else:
		return [(curr_pos[0], curr_pos[1] + 1), (curr_pos[0], curr_pos[1] - 1), (curr_pos[0] + 1, curr_pos[1]), (curr_pos[0] - 1, curr_pos[1])]

def get_light_state(matrix):
	for i in range(3):
		for j in range(3):
			if matrix[i][j] % 2:
				matrix[i][j] = 0
			else:
				matrix[i][j] = 1
matrix = []
for i in range(3):
	inp = input().split()
	inp = [int(x) for x in inp]
	matrix.append(inp)
matrix_copy = [x[:] for x in matrix]
for i in range(3):
	for j in range(3):
		curr_pos = (i, j)
		adjacents = get_side_adjacents(matrix, curr_pos)
		for adj in adjacents:
			matrix_copy[adj[0]][adj[1]] += matrix[i][j]
get_light_state(matrix_copy)
for i in range(3):
	curr_line = ''
	for j in range(3):
		curr_line += str(matrix_copy[i][j])
	print(curr_line)


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


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

def valid(x, y):
	return x >= 0 and x <= 2 and (y <= 2) and (y >= 0)

def apply(_x, _y):
	grid[_x][_y] += inp[_x][_y]
	for d in range(0, 4):
		if valid(_x + dx[d], _y + dy[d]):
			grid[_x + dx[d]][_y + dy[d]] += inp[_x][_y]
grid = [[1] * 3 for _ in range(3)]
inp = [list(map(int, input().split())) for i in range(3)]
for i in range(0, 3):
	for j in range(0, 3):
		if inp[i][j]:
			apply(i, j)
for i in range(0, 3):
	for j in range(0, 3):
		print(grid[i][j] % 2, end='')
	print('')


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

def change(x, y):
	a = rows[x][y]
	if a == 0:
		rows[x][y] = 1
	else:
		rows[x][y] = 0
for x in range(3):
	string = input()
	presses = list(map(int, string.split()))
	for y in range(3):
		if presses[y] % 2 == 1:
			change(x, y)
			if y < 2:
				change(x, y + 1)
			if y > 0:
				change(x, y - 1)
			if x < 2:
				change(x + 1, y)
			if x > 0:
				change(x - 1, y)
for x in rows:
	print(''.join(map(str, x)))


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)
for row in range(3):
	for col in range(3):
		print(result[row][col], end='')
	print()


init = [[1] * 3, [1] * 3, [1] * 3]
inp1 = list(map(int, input().split()))
inp2 = list(map(int, input().split()))
inp3 = list(map(int, input().split()))
if inp1[0] % 2 == 1:
	init[0][0] = 1 - init[0][0]
	init[0][1] = 1 - init[0][1]
	init[1][0] = 1 - init[1][0]
if inp1[1] % 2 == 1:
	init[0][1] = 1 - init[0][1]
	init[0][2] = 1 - init[0][2]
	init[1][1] = 1 - init[1][1]
	init[0][0] = 1 - init[0][0]
if inp1[2] % 2 == 1:
	init[0][2] = 1 - init[0][2]
	init[0][1] = 1 - init[0][1]
	init[1][2] = 1 - init[1][2]
if inp2[0] % 2 == 1:
	init[1][0] = 1 - init[1][0]
	init[0][0] = 1 - init[0][0]
	init[2][0] = 1 - init[2][0]
	init[1][1] = 1 - init[1][1]
if inp2[1] % 2 == 1:
	init[1][1] = 1 - init[1][1]
	init[0][1] = 1 - init[0][1]
	init[2][1] = 1 - init[2][1]
	init[1][0] = 1 - init[1][0]
	init[1][2] = 1 - init[1][2]
if inp2[2] % 2 == 1:
	init[1][2] = 1 - init[1][2]
	init[0][2] = 1 - init[0][2]
	init[2][2] = 1 - init[2][2]
	init[1][1] = 1 - init[1][1]
if inp3[0] % 2 == 1:
	init[2][0] = 1 - init[2][0]
	init[2][1] = 1 - init[2][1]
	init[1][0] = 1 - init[1][0]
if inp3[1] % 2 == 1:
	init[2][1] = 1 - init[2][1]
	init[2][2] = 1 - init[2][2]
	init[2][0] = 1 - init[2][0]
	init[1][1] = 1 - init[1][1]
if inp3[2] % 2 == 1:
	init[2][2] = 1 - init[2][2]
	init[2][1] = 1 - init[2][1]
	init[1][2] = 1 - init[1][2]
for x in init:
	for y in x:
		print(y, end='')
	print()


arr = [[0] * 5 for _ in range(5)]
for i in range(1, 4):
	(arr[i][1], arr[i][2], arr[i][3]) = map(int, input().split())
for i in range(1, 4):
	for j in range(1, 4):
		print(0 if (arr[i][j] + arr[i][j - 1] + arr[i][j + 1] + arr[i + 1][j] + arr[i - 1][j]) % 2 else 1, end='')
	print()


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

def toggle(i, j, saida):
	saida[i][j] += 1
	if i > 0:
		saida[i - 1][j] += 1
	if i < 2:
		saida[i + 1][j] += 1
	if j > 0:
		saida[i][j - 1] += 1
	if j < 2:
		saida[i][j + 1] += 1
	return saida
for i in range(3):
	for j in range(3):
		if grid[i][j] % 2 == 1:
			saida = toggle(i, j, saida)
for m in range(3):
	for n in range(3):
		print(saida[m][n] % 2, end='')
	print('\n', end='')


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


arr = []
for i in range(3):
	arr.append(input().split(' '))
res = [['1', '1', '1'] for i in range(3)]
for i in range(3):
	for j in range(3):
		if arr[i][j] != '0':
			if int(arr[i][j]) % 2 == 0:
				pass
			else:
				if res[i][j] == '1':
					res[i][j] = '0'
				else:
					res[i][j] = '1'
				if i + 1 < 3:
					if res[i + 1][j] == '1':
						res[i + 1][j] = '0'
					else:
						res[i + 1][j] = '1'
				if i - 1 >= 0:
					if res[i - 1][j] == '1':
						res[i - 1][j] = '0'
					else:
						res[i - 1][j] = '1'
				if j + 1 < 3:
					if res[i][j + 1] == '1':
						res[i][j + 1] = '0'
					else:
						res[i][j + 1] = '1'
				if j - 1 >= 0:
					if res[i][j - 1] == '1':
						res[i][j - 1] = '0'
					else:
						res[i][j - 1] = '1'
for i in res:
	print(''.join(i))


m = []
for x in range(3):
	m.append([int(x) % 2 for x in input().split()])
i = 0
for i in range(3):
	j = 0
	state = 0
	c_out = ''
	for j in range(3):
		state = m[i][j]
		if i != 0:
			state += m[i - 1][j]
		if i != 2:
			state += m[i + 1][j]
		if j != 0:
			state += m[i][j - 1]
		if j != 2:
			state += m[i][j + 1]
		if state % 2:
			c_out += '0'
		else:
			c_out += '1'
	print(c_out)


a = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	l = list(map(int, input().split()))
	for j in range(3):
		if l[j] % 2 == 1:
			a[i][j] = 1 - a[i][j]
			if j - 1 >= 0:
				a[i][j - 1] = 1 - a[i][j - 1]
			if j + 1 < 3:
				a[i][j + 1] = 1 - a[i][j + 1]
			if i - 1 >= 0:
				a[i - 1][j] = 1 - a[i - 1][j]
			if i + 1 < 3:
				a[i + 1][j] = 1 - a[i + 1][j]
for i in range(3):
	for j in range(3):
		a[i][j] = str(a[i][j])
	print(''.join(a[i]))


def toggle(val):
	if val == 1:
		return 0
	else:
		return 1
timed = [list(map(int, input().split())) 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])
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])
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])
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])
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])
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])
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])
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])
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])
for i in range(3):
	for j in range(3):
		print(curr_state[i][j], end='')
	print()


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


def toggle_light(mat, i, j):
	mat[i][j] = not mat[i][j]
	if 0 <= i <= 1:
		mat[i + 1][j] = not mat[i + 1][j]
	if 0 <= j <= 1:
		mat[i][j + 1] = not mat[i][j + 1]
	if 1 <= i <= 2:
		mat[i - 1][j] = not mat[i - 1][j]
	if 1 <= j <= 2:
		mat[i][j - 1] = not mat[i][j - 1]

def main():
	mat = [[1] * 3 for _ in range(3)]
	for i in range(3):
		row = list(map(int, input().split()))
		for j in range(3):
			if row[j] % 2:
				toggle_light(mat, i, j)
	print('\n'.join((''.join(map(str, map(int, row))) for row in mat)))
main()


m = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]
l = [[int(i) for i in input().split()] for j in range(3)]
for i in range(3):
	for j in range(3):
		if l[i][j] == 0 or l[i][j] % 2 == 0:
			continue
		else:
			if m[i + 1][j + 1] == 0:
				m[i + 1][j + 1] = 1
			else:
				m[i + 1][j + 1] = 0
			if m[i][j + 1] == 0:
				m[i][j + 1] = 1
			else:
				m[i][j + 1] = 0
			if m[i + 1][j] == 0:
				m[i + 1][j] = 1
			else:
				m[i + 1][j] = 0
			if m[i + 2][j + 1] == 0:
				m[i + 2][j + 1] = 1
			else:
				m[i + 2][j + 1] = 0
			if m[i + 1][j + 2] == 0:
				m[i + 1][j + 2] = 1
			else:
				m[i + 1][j + 2] = 0
t = [[m[1][1], m[1][2], m[1][3]], [m[2][1], m[2][2], m[2][3]], [m[3][1], m[3][2], m[3][3]]]
for i in t:
	for j in i:
		print(j, end='')
	print()


def numOfClicks(i, j, clicks, rows, cols):
	positions = [[-1, 0], [0, -1], [0, 0], [0, 1], [1, 0]]
	click = 0
	for pos in positions:
		if 0 <= i + pos[0] < rows and 0 <= j + pos[1] < cols:
			click += int(clicks[i + pos[0]][j + pos[1]])
	return click
clicks = []
for i in range(3):
	clicks.append(input().split())
lights = [['1', '1', '1'], ['1', '1', '1'], ['1', '1', '1']]
for i in range(len(clicks)):
	for j in range(len(clicks[0])):
		if numOfClicks(i, j, clicks, len(clicks), len(clicks[0])) % 2 == 0:
			lights[i][j] = '1'
		else:
			lights[i][j] = '0'
for i in range(len(lights)):
	print('{0}'.format(''.join(lights[i])))


l = []
x = []
for i in range(3):
	x.append(list(map(int, input().split())))
temp = []
temp.append(1)
temp.append(1)
temp.append(1)
for i in range(3):
	l.append(list(temp))
for i in range(3):
	for j in range(3):
		if x[i][j] % 2 == 1:
			l[i][j] = l[i][j] ^ 1
			if i + 1 < 3:
				l[i + 1][j] = l[i + 1][j] ^ 1
			if j + 1 < 3:
				l[i][j + 1] = l[i][j + 1] ^ 1
			if i - 1 >= 0:
				l[i - 1][j] = l[i - 1][j] ^ 1
			if j - 1 >= 0:
				l[i][j - 1] = l[i][j - 1] ^ 1
for i in range(3):
	print(*l[i], sep='')


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


def t(n):
	if n % 2 == 0:
		return 1
	else:
		return 0
l = []
for j in range(3):
	a = list(map(int, input().split()))
	for i in range(3):
		a[i] = a[i] % 2
	l.append(a)
q = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	for j in range(3):
		if l[i][j] == 1:
			q[i][j] = t(q[i][j])
			if i == 0:
				q[i + 1][j] = t(q[i + 1][j])
				if j == 0:
					q[i][j + 1] = t(q[i][j + 1])
				elif j == 1:
					q[i][j + 1] = t(q[i][j + 1])
					q[i][j - 1] = t(q[i][j - 1])
				else:
					q[i][j - 1] = t(q[i][j - 1])
			elif i == 1:
				q[i + 1][j] = t(q[i + 1][j])
				q[i - 1][j] = t(q[i - 1][j])
				if j == 0:
					q[i][j + 1] = t(q[i][j + 1])
				elif j == 1:
					q[i][j + 1] = t(q[i][j + 1])
					q[i][j - 1] = t(q[i][j - 1])
				else:
					q[i][j - 1] = t(q[i][j - 1])
			elif i == 2:
				q[i - 1][j] = t(q[i - 1][j])
				if j == 0:
					q[i][j + 1] = t(q[i][j + 1])
				elif j == 1:
					q[i][j + 1] = t(q[i][j + 1])
					q[i][j - 1] = t(q[i][j - 1])
				else:
					q[i][j - 1] = t(q[i][j - 1])
for i in range(3):
	for j in range(3):
		print(q[i][j], end='')
	print()


final = []
lights = [[0, 0, 0, 0, 0]]
for i in range(3):
	x = list(map(int, input().split()))
	x = [0] + x + [0]
	lights.append(x)
lights.append([0, 0, 0, 0, 0])
for i in range(1, 4):
	for j in range(1, 4):
		final.append(lights[i][j] + lights[i - 1][j] + lights[i][j - 1] + lights[i + 1][j] + lights[i][j + 1])
for i in range(9):
	print(int(not final[i] % 2), end='')
	if (i + 1) % 3 == 0:
		print()


board = []
for i in range(3):
	temp = [int(x) for x in input().split(' ')]
	board.append(temp)
line1 = ''
adjacent = board[0][0] + board[0][1] + board[1][0]
if adjacent % 2 == 1:
	line1 += '0'
else:
	line1 += '1'
adjacent = board[0][0] + board[0][1] + board[0][2] + board[1][1]
if adjacent % 2 == 1:
	line1 += '0'
else:
	line1 += '1'
adjacent = board[0][2] + board[0][1] + board[1][2]
if adjacent % 2 == 1:
	line1 += '0'
else:
	line1 += '1'
line2 = ''
adjacent = board[0][0] + board[1][1] + board[1][0] + board[2][0]
if adjacent % 2 == 1:
	line2 += '0'
else:
	line2 += '1'
adjacent = board[0][1] + board[1][1] + board[1][2] + board[1][0] + board[2][1]
if adjacent % 2 == 1:
	line2 += '0'
else:
	line2 += '1'
adjacent = board[0][2] + board[1][1] + board[1][2] + board[2][2]
if adjacent % 2 == 1:
	line2 += '0'
else:
	line2 += '1'
line3 = ''
adjacent = board[2][0] + board[1][0] + board[2][1]
if adjacent % 2 == 1:
	line3 += '0'
else:
	line3 += '1'
adjacent = board[2][1] + board[2][0] + board[2][2] + board[1][1]
if adjacent % 2 == 1:
	line3 += '0'
else:
	line3 += '1'
adjacent = board[2][2] + board[2][1] + board[1][2]
if adjacent % 2 == 1:
	line3 += '0'
else:
	line3 += '1'
print('{}\n{}\n{}'.format(line1, line2, line3))


def sideEffect(matrix, i, j):
	if matrix[i][j] == '1':
		matrix[i][j] = '0'
	elif matrix[i][j] == '0':
		matrix[i][j] = '1'
	if i - 1 >= 0 and matrix[i - 1][j]:
		if matrix[i - 1][j] == '0':
			matrix[i - 1][j] = '1'
		elif matrix[i - 1][j] == '1':
			matrix[i - 1][j] = '0'
	if j + 1 < 3 and matrix[i][j + 1]:
		if matrix[i][j + 1] == '0':
			matrix[i][j + 1] = '1'
		elif matrix[i][j + 1] == '1':
			matrix[i][j + 1] = '0'
	if i + 1 < 3 and matrix[i + 1][j]:
		if matrix[i + 1][j] == '0':
			matrix[i + 1][j] = '1'
		elif matrix[i + 1][j] == '1':
			matrix[i + 1][j] = '0'
	if j - 1 >= 0 and matrix[i][j - 1]:
		if matrix[i][j - 1] == '0':
			matrix[i][j - 1] = '1'
		elif matrix[i][j - 1] == '1':
			matrix[i][j - 1] = '0'
	return matrix
matrix01 = [['1', '1', '1'], ['1', '1', '1'], ['1', '1', '1']]
matrix = []
for i in range(3):
	line = input()
	line = line.split()
	matrix.append(line)
for i in range(3):
	for j in range(3):
		pos = matrix[i][j]
		for a in range(int(pos)):
			matrix01 = sideEffect(matrix01, i, j)
for line in matrix01:
	print(line[0] + line[1] + line[2])


states = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for row in range(3):
	each_row = list(map(int, input().split()))
	for col in range(3):
		if row == 0 and col == 0:
			states[0][0] = (states[0][0] + each_row[col]) % 2
			states[1][0] = (states[1][0] + each_row[col]) % 2
			states[0][1] = (states[0][1] + each_row[col]) % 2
		elif row == 0 and col == 1:
			states[0][0] = (states[0][0] + each_row[col]) % 2
			states[0][1] = (states[0][1] + each_row[col]) % 2
			states[0][2] = (states[0][2] + each_row[col]) % 2
			states[1][1] = (states[1][1] + each_row[col]) % 2
		elif row == 0 and col == 2:
			states[0][2] = (states[0][2] + each_row[col]) % 2
			states[1][2] = (states[1][2] + each_row[col]) % 2
			states[0][1] = (states[0][1] + each_row[col]) % 2
		elif row == 1 and col == 0:
			states[0][0] = (states[0][0] + each_row[col]) % 2
			states[1][0] = (states[1][0] + each_row[col]) % 2
			states[1][1] = (states[1][1] + each_row[col]) % 2
			states[2][0] = (states[2][0] + each_row[col]) % 2
		elif row == 1 and col == 1:
			states[1][1] = (states[1][1] + each_row[col]) % 2
			states[0][1] = (states[0][1] + each_row[col]) % 2
			states[1][2] = (states[1][2] + each_row[col]) % 2
			states[1][0] = (states[1][0] + each_row[col]) % 2
			states[2][1] = (states[2][1] + each_row[col]) % 2
		elif row == 1 and col == 2:
			states[1][2] = (states[1][2] + each_row[col]) % 2
			states[0][2] = (states[0][2] + each_row[col]) % 2
			states[1][1] = (states[1][1] + each_row[col]) % 2
			states[2][2] = (states[2][2] + each_row[col]) % 2
		elif row == 2 and col == 0:
			states[1][0] = (states[1][0] + each_row[col]) % 2
			states[2][1] = (states[2][1] + each_row[col]) % 2
			states[2][0] = (states[2][0] + each_row[col]) % 2
		elif row == 2 and col == 1:
			states[2][2] = (states[2][2] + each_row[col]) % 2
			states[1][1] = (states[1][1] + each_row[col]) % 2
			states[2][0] = (states[2][0] + each_row[col]) % 2
			states[2][1] = (states[2][1] + each_row[col]) % 2
		else:
			states[1][2] = (states[1][2] + each_row[col]) % 2
			states[2][1] = (states[2][1] + each_row[col]) % 2
			states[2][2] = (states[2][2] + each_row[col]) % 2
for row in range(3):
	print(''.join(map(str, states[row])))


n = 3
m = []
for i in range(n):
	a = list(map(int, input().split()))
	m.append(a)
k00 = (m[0][0] + m[0][1] + m[1][0]) % 2
if k00 == 1:
	k00 = 0
else:
	k00 = 1
k01 = (m[1][1] + m[0][0] + m[0][2] + m[0][1]) % 2
if k01 == 1:
	k01 = 0
else:
	k01 = 1
k02 = (m[0][1] + m[0][2] + m[1][2]) % 2
if k02 == 1:
	k02 = 0
else:
	k02 = 1
k20 = (m[2][0] + m[1][0] + m[2][1]) % 2
if k20 == 1:
	k20 = 0
else:
	k20 = 1
k22 = (m[2][2] + m[2][1] + m[1][2]) % 2
if k22 == 1:
	k22 = 0
else:
	k22 = 1
k10 = (m[1][1] + m[0][0] + m[2][0] + m[1][0]) % 2
if k10 == 1:
	k10 = 0
else:
	k10 = 1
k12 = (m[1][1] + m[0][2] + m[2][2] + m[1][2]) % 2
if k12 == 1:
	k12 = 0
else:
	k12 = 1
k21 = (m[1][1] + m[2][0] + m[2][2] + m[2][1]) % 2
if k21 == 1:
	k21 = 0
else:
	k21 = 1
k11 = (m[1][1] + m[1][0] + m[1][2] + m[0][1] + m[2][1]) % 2
if k11 == 1:
	k11 = 0
else:
	k11 = 1
ans = [[k00, k01, k02], [k10, k11, k12], [k20, k21, k22]]
for i in range(3):
	for j in range(3):
		print(ans[i][j], end='')
	print('\n', end='')


lights = []
for i in range(3):
	temp = input().split(' ')
	temp = [int(x) for x in temp]
	lights.append(temp)
results = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
nrows = 3
ncol = 3
for i in range(nrows):
	for j in range(ncol):
		if lights[i][j] % 2 != 0:
			if i - 1 >= 0:
				results[i - 1][j] = 1 - results[i - 1][j]
			if j - 1 >= 0:
				results[i][j - 1] = 1 - results[i][j - 1]
			results[i][j] = 1 - results[i][j]
			if j + 1 <= ncol - 1:
				results[i][j + 1] = 1 - results[i][j + 1]
			if i + 1 <= nrows - 1:
				results[i + 1][j] = 1 - results[i + 1][j]
for i in range(3):
	print(''.join((str(item) for item in results[i])))


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


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


from collections import defaultdict
d = defaultdict(int)
arr = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
a = []
for i in range(3):
	listt = list(map(int, input().split()))
	a.append(listt)
	for j in range(3):
		arr[i][j] = listt[j] % 2
listt = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
	for j in range(3):
		listt[i][j] = arr[i][j]
for i in range(3):
	for j in range(3):
		if arr[i][j]:
			if i - 1 in range(3):
				listt[i - 1][j] += 1
			if i + 1 in range(3):
				listt[i + 1][j] += 1
			if j - 1 in range(3):
				listt[i][j - 1] += 1
			if j + 1 in range(3):
				listt[i][j + 1] += 1
ans = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
	for j in range(3):
		ans[i][j] = 0 if listt[i][j] % 2 else 1
		print(ans[i][j], end='')
	print()


from sys import stdin

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


lights = []
lst = []
for i in range(3):
	lst.append(list(map(int, input().split())))
	temp = [1] * 3
	lights.append(temp)
for i in range(3):
	for j in range(3):
		if lst[i][j] > 0:
			if lst[i][j] % 2 != 0:
				if lights[i][j] == 0:
					lights[i][j] = 1
				else:
					lights[i][j] = 0
				if i + 1 < 3:
					if lights[i + 1][j] == 0:
						lights[i + 1][j] = 1
					else:
						lights[i + 1][j] = 0
				if i - 1 > -1:
					if lights[i - 1][j] == 0:
						lights[i - 1][j] = 1
					else:
						lights[i - 1][j] = 0
				if j + 1 < 3:
					if lights[i][j + 1] == 0:
						lights[i][j + 1] = 1
					else:
						lights[i][j + 1] = 0
				if j - 1 > -1:
					if lights[i][j - 1] == 0:
						lights[i][j - 1] = 1
					else:
						lights[i][j - 1] = 0
for i in range(3):
	print(*lights[i], sep='')


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


d = dict()
ans = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
	d[i] = list(map(int, input().split()))
for i in range(3):
	for j in range(3):
		if i == 0 and j == 0:
			s = d[0][1] + d[1][0]
		elif i == 0 and j == 1:
			s = d[0][0] + d[0][2] + d[1][1]
		elif i == 0 and j == 2:
			s = d[0][1] + d[1][2]
		elif i == 1 and j == 0:
			s = d[0][0] + d[1][1] + d[2][0]
		elif i == 1 and j == 1:
			s = d[0][1] + d[1][0] + d[2][1] + d[1][2]
		elif i == 1 and j == 2:
			s = d[0][2] + d[1][1] + d[2][2]
		elif i == 2 and j == 0:
			s = d[1][0] + d[2][1]
		elif i == 2 and j == 1:
			s = d[2][0] + d[1][1] + d[2][2]
		elif i == 2 and j == 2:
			s = d[2][1] + d[1][2]
		else:
			continue
		if s % 2 == 1:
			ans[i][j] = d[i][j] % 2
		else:
			ans[i][j] = 1 - d[i][j] % 2
for i in range(3):
	for j in range(3):
		print(ans[i][j], end='')
	print()


s = []
for _ in range(0, 3):
	s.append(list(map(int, input().rstrip().split())))
res = []
res.append([1, 1, 1])
res.append([1, 1, 1])
res.append([1, 1, 1])
for i in range(0, 3):
	for j in range(0, 3):
		c = 0
		while c < s[i][j]:
			if res[i][j] == 0:
				res[i][j] = 1
			elif res[i][j] == 1:
				res[i][j] = 0
			if i > 0:
				if res[i - 1][j] == 0:
					res[i - 1][j] = 1
				elif res[i - 1][j] == 1:
					res[i - 1][j] = 0
			if j < 2:
				if res[i][j + 1] == 0:
					res[i][j + 1] = 1
				elif res[i][j + 1] == 1:
					res[i][j + 1] = 0
			if i < 2:
				if res[i + 1][j] == 0:
					res[i + 1][j] = 1
				elif res[i + 1][j] == 1:
					res[i + 1][j] = 0
			if j > 0:
				if res[i][j - 1] == 0:
					res[i][j - 1] = 1
				elif res[i][j - 1] == 1:
					res[i][j - 1] = 0
			c += 1
a = str(res[0][0]) + str(res[0][1]) + str(res[0][2])
print(a)
print(str(res[1][0]) + str(res[1][1]) + str(res[1][2]))
print(str(res[2][0]) + str(res[2][1]) + str(res[2][2]))


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

def change(l, h):
	kas = l[h]
	if kas == 1:
		l[h] = 0
	if kas == 0:
		l[h] = 1
for d in range(3):
	if j[d] % 2 != 0 and j[d] != 0:
		change(k, d)
		if d != 2:
			change(k, d + 1)
		if d != 0:
			change(k, d - 1)
		change(k, d + 3)
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)
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)
		change(k, d - 3)
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)


lights = [[int(x) for x in input().split()] for _ in range(3)]
new_lights = [[1 for _ in range(3)] for __ in range(3)]
adj_map = [(+1, 0), (-1, 0), (0, +1), (0, -1)]
for i in range(3):
	for j in range(3):
		for adj in adj_map:
			(x, y) = (i + adj[0], j + adj[1])
			if x >= 0 and y >= 0 and (x < 3) and (y < 3):
				new_lights[x][y] += lights[i][j]
		new_lights[i][j] += lights[i][j]
for line in new_lights:
	print(''.join([str(x % 2) for x in line]))


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


def getToggleCase(row, clm):
	global toggles, lights
	toggles[row][clm] -= 1
	if row == 0:
		if clm == 0:
			toggle(row, clm)
			toggle(row, clm + 1)
			toggle(row + 1, clm)
		elif clm == 1:
			toggle(row, clm)
			toggle(row, clm + 1)
			toggle(row, clm - 1)
			toggle(row + 1, clm)
		elif clm == 2:
			toggle(row, clm)
			toggle(row, clm - 1)
			toggle(row + 1, clm)
	elif row == 1:
		if clm == 0:
			toggle(row, clm)
			toggle(row - 1, clm)
			toggle(row + 1, clm)
			toggle(row, clm + 1)
		elif clm == 1:
			toggle(row, clm)
			toggle(row - 1, clm)
			toggle(row, clm - 1)
			toggle(row, clm + 1)
			toggle(row + 1, clm)
		elif clm == 2:
			toggle(row, clm)
			toggle(row - 1, clm)
			toggle(row + 1, clm)
			toggle(row, clm - 1)
	elif row == 2:
		if clm == 0:
			toggle(row, clm)
			toggle(row - 1, clm)
			toggle(row, clm + 1)
		elif clm == 1:
			toggle(row, clm)
			toggle(row - 1, clm)
			toggle(row, clm - 1)
			toggle(row, clm + 1)
		elif clm == 2:
			toggle(row, clm)
			toggle(row - 1, clm)
			toggle(row, clm - 1)

def toggle(row, clm):
	global lights
	if lights[row][clm] == 0:
		lights[row][clm] = 1
	else:
		lights[row][clm] = 0
toggles = []
lights = [[1 for i in range(3)] for j in range(3)]
for r in range(3):
	toggles.append(list(map(int, input().rstrip().split())))
for i in range(3):
	for j in range(3):
		while toggles[i][j] > 0:
			getToggleCase(i, j)
print(''.join((str(x) for x in lights[0])))
print(''.join((str(x) for x in lights[1])))
print(''.join((str(x) for x in lights[2])))


initial = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
x = []
x.append(['t', 't', 't', 't', 't'])
for i in range(3):
	temp = ['t']
	t = list(map(int, input().split()))
	for j in t:
		temp.append(j)
	temp.append('t')
	x.append(temp)
x.append(['t', 't', 't', 't', 't'])
ans = []
for i in range(1, 4):
	res = ''
	for j in range(1, 4):
		s = 0
		s += x[i][j]
		if x[i][j - 1] != 't':
			s += x[i][j - 1]
		if x[i][j + 1] != 't':
			s += x[i][j + 1]
		if x[i - 1][j] != 't':
			s += x[i - 1][j]
		if x[i + 1][j] != 't':
			s += x[i + 1][j]
		if s % 2 == 0:
			res += '1'
		else:
			res += '0'
	print(res)


mylist = list()
mylist.append(list(map(int, input().split())))
mylist.append(list(map(int, input().split())))
mylist.append(list(map(int, input().split())))
bulbState = list()
print(1 if (mylist[0][0] + mylist[1][0] + mylist[0][1]) % 2 == 0 else 0, end='')
print(1 if (mylist[0][0] + mylist[0][1] + mylist[1][1] + mylist[0][2]) % 2 == 0 else 0, end='')
print(1 if (mylist[0][2] + mylist[1][2] + mylist[0][1]) % 2 == 0 else 0, end='')
print()
print(1 if (mylist[1][0] + mylist[0][0] + mylist[2][0] + mylist[1][1]) % 2 == 0 else 0, end='')
print(1 if (mylist[0][1] + mylist[1][1] + mylist[1][0] + mylist[2][1] + mylist[1][2]) % 2 == 0 else 0, end='')
print(1 if (mylist[1][1] + mylist[0][2] + mylist[2][2] + mylist[1][2]) % 2 == 0 else 0, end='')
print()
print(1 if (mylist[2][0] + mylist[1][0] + mylist[2][1]) % 2 == 0 else 0, end='')
print(1 if (mylist[2][1] + mylist[2][0] + mylist[2][2] + mylist[1][1]) % 2 == 0 else 0, end='')
print(1 if (mylist[2][2] + mylist[1][2] + mylist[2][1]) % 2 == 0 else 0, end='')


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


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


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

def switch(a):
	if int(a) == 0:
		return 1
	else:
		return 0
for a in range(len(i)):
	for b in range(len(i[a])):
		if int(i[a][b]) % 2 == 0 and int(i[a][b]) != 0:
			pass
		elif int(i[a][b]) % 2 == 1 and int(i[a][b]) != 0:
			l[a][b] = switch(l[a][b])
			if a != 0:
				l[a - 1][b] = switch(l[a - 1][b])
			if a != 2:
				l[a + 1][b] = switch(l[a + 1][b])
			if b != 0:
				l[a][b - 1] = switch(l[a][b - 1])
			if b != 2:
				l[a][b + 1] = switch(l[a][b + 1])
for i in range(3):
	print(str(l[i][0]) + str(l[i][1]) + str(l[i][2]))


n = 3
matrix = [[0 for i in range(n)] for j in range(n)]
ans = [[1 for i in range(n)] for j in range(n)]
for i in range(n):
	matrix[i] = input().split(' ')
for i in range(n):
	for j in range(n):
		if int(matrix[i][j]) % 2 == 1:
			ans[i][j] = int(ans[i][j] + 1) % 2
			if i - 1 >= 0:
				ans[i - 1][j] = int(ans[i - 1][j] + 1) % 2
			if i + 1 < n:
				ans[i + 1][j] = int(ans[i + 1][j] + 1) % 2
			if j + 1 < n:
				ans[i][j + 1] = int(ans[i][j + 1] + 1) % 2
			if j - 1 >= 0:
				ans[i][j - 1] = int(ans[i][j - 1] + 1) % 2
for i in range(n):
	for j in range(n):
		print(ans[i][j], end='')
	print()


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)


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


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


def switch(value):
	return (value + 1) % 2

def adjacent(starting_game, i, j):
	starting_game[i][j] = switch(starting_game[i][j])
	if i != 0:
		starting_game[i - 1][j] = switch(starting_game[i - 1][j])
	if j != 0:
		starting_game[i][j - 1] = switch(starting_game[i][j - 1])
	if i != 2:
		starting_game[i + 1][j] = switch(starting_game[i + 1][j])
	if j != 2:
		starting_game[i][j + 1] = switch(starting_game[i][j + 1])
	return starting_game
starting_game = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
press_sequence = []
for i in range(3):
	pressing = input().split()
	pressing = [int(x) for x in pressing]
	press_sequence.append(pressing)
for i in range(3):
	for j in range(3):
		if press_sequence[i][j] % 2 != 0:
			starting_game = adjacent(starting_game, i, j)
for result in starting_game:
	result = [str(x) for x in result]
	print(''.join(result))


arr = []
for i in range(3):
	arr.append([1, 1, 1])
mat = list()
for i in range(3):
	row = list(map(int, input().split()))
	mat.append(row)
for i in range(3):
	for j in range(3):
		if mat[i][j] % 2 != 0:
			if arr[i][j]:
				arr[i][j] = 0
			else:
				arr[i][j] = 1
			if i != 0:
				if arr[i - 1][j]:
					arr[i - 1][j] = 0
				else:
					arr[i - 1][j] = 1
			if i != 2:
				if arr[i + 1][j]:
					arr[i + 1][j] = 0
				else:
					arr[i + 1][j] = 1
			if j != 2:
				if arr[i][j + 1]:
					arr[i][j + 1] = 0
				else:
					arr[i][j + 1] = 1
			if j != 0:
				if arr[i][j - 1]:
					arr[i][j - 1] = 0
				else:
					arr[i][j - 1] = 1
for i in arr:
	for j in i:
		print(j, end='')
	print()


a = input().split()
b = input().split()
c = input().split()
lis = [a, b, c]
for i in range(3):
	for j in range(3):
		lis[i][j] = int(lis[i][j])
newl = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
	newl[0][i] = lis[0][i] + lis[1][i]
	newl[2][i] = lis[2][i] + lis[1][i]
	newl[1][i] = lis[0][i] + lis[1][i] + lis[2][i]
for i in range(3):
	newl[i][0] = (newl[i][0] + lis[i][1] + 1) % 2
	newl[i][2] = (newl[i][2] + lis[i][1] + 1) % 2
	newl[i][1] = (newl[i][1] + lis[i][0] + lis[i][2] + 1) % 2
print(str(newl[0][0]) + str(newl[0][1]) + str(newl[0][2]))
print(str(newl[1][0]) + str(newl[1][1]) + str(newl[1][2]))
print(str(newl[2][0]) + str(newl[2][1]) + str(newl[2][2]))


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


def lights_out(l, l_initial):
	flag = 1
	i = 0
	while i <= len(l) - 1:
		j = 0
		while j <= n - 1:
			if l[i][j] % 2 == 0:
				flag = 1
				j = j + 1
			else:
				for k in range(1, l[i][j] + 1):
					if k % 2 != 0:
						flag = 0
						l_initial[i][j] = abs(l_initial[i][j] - 1)
					else:
						flag = 1
						l_initial[i][j] = abs(l_initial[i][j] - 1)
				if flag == 0:
					a = i + j
					for x in range(len(l)):
						for y in range(n):
							if x + y == a + 1 and (x == i or y == j):
								l_initial[x][y] = abs(l_initial[x][y] - 1)
							elif x + y == a - 1 and (x == i or y == j):
								l_initial[x][y] = abs(l_initial[x][y] - 1)
				else:
					pass
				j = j + 1
		i = i + 1
	for i in l_initial:
		print(*i, sep='')
l = []
n = 3
for i in range(n):
	l.append(list(map(int, input().split())))
l_initial = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
lights_out(l, l_initial)


grid = [[int(c) for c in input().split()] for _ in range(3)]
res = [[1] * 3 for _ in range(3)]
neighbors = [(0, 0), (-1, 0), (1, 0), (0, -1), (0, 1)]
for row in range(3):
	for col in range(3):
		e = grid[row][col]
		if e % 2 != 0:
			for (r, c) in neighbors:
				(rr, cc) = (r + row, c + col)
				if 0 <= rr < 3 and 0 <= cc < 3:
					res[rr][cc] = 1 - res[rr][cc]
for row in res:
	print(*row, sep='')


def toogle(s, i, j, moves):
	if moves % 2 != 0:
		for (x, y) in ((0, 0), (1, 0), (0, -1), (-1, 0), (0, 1)):
			s[i + x][j + y] = int(not bool(s[i + x][j + y]))
	return s
s = [[1] * 5 for _ in range(5)]
entrada = [list(map(int, input().split())) for _ in (1, 2, 3)]
for i in range(1, 4):
	for j in range(1, 4):
		s = toogle(s, i, j, entrada[i - 1][j - 1])
for i in (1, 2, 3):
	for j in (1, 2, 3):
		print(s[i][j], end='')
	print()


start = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
inp = []
for i in range(3):
	inp.append([int(x) for x in input().split()])
moves = [[0, 1], [1, 0], [0, -1], [-1, 0], [0, 0]]
ans = []
for i in range(3):
	for j in range(3):
		s = 0
		for k in range(5):
			newi = i + moves[k][0]
			newj = j + moves[k][1]
			if newi >= 0 and newi < 3 and (newj >= 0) and (newj < 3):
				s += inp[newi][newj]
		if s % 2 == 1:
			start[i][j] = '0'
		else:
			start[i][j] = '1'
for i in start:
	print(''.join(i))


res = []
for i in range(3):
	res.append([True, True, True])
mat = []
for i in range(3):
	mat.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		if mat[i][j] % 2 != 0:
			res[i][j] = not res[i][j]
			if i != 0:
				res[i - 1][j] = not res[i - 1][j]
			if j != 0:
				res[i][j - 1] = not res[i][j - 1]
			if i != 2:
				res[i + 1][j] = not res[i + 1][j]
			if j != 2:
				res[i][j + 1] = not res[i][j + 1]
for i in range(3):
	for j in range(3):
		if res[i][j]:
			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)


inMatrix = []
for _ in range(3):
	inMatrix.append(list(map(int, input().split())))
outMatrix = [[1 for i in range(3)] for j in range(3)]
for i in range(3):
	for j in range(3):
		pressCount = inMatrix[i][j]
		if i - 1 >= 0:
			pressCount += inMatrix[i - 1][j]
		if j - 1 >= 0:
			pressCount += inMatrix[i][j - 1]
		if i + 1 <= 2:
			pressCount += inMatrix[i + 1][j]
		if j + 1 <= 2:
			pressCount += inMatrix[i][j + 1]
		if pressCount % 2 != 0:
			outMatrix[i][j] = 0
for i in range(3):
	print(*outMatrix[i], sep='')


m = []
for i in range(3):
	m.append([int(q) for q in input().split()])
z = [[0 for i in range(3)] for j in range(3)]
z[0][0] = m[0][0] + m[0][1] + m[1][0]
z[0][1] = m[0][0] + m[0][1] + m[0][2] + m[1][1]
z[0][2] = m[0][1] + m[0][2] + m[1][2]
z[1][0] = m[0][0] + m[2][0] + m[1][0] + m[1][1]
z[1][1] = m[0][1] + m[1][0] + m[1][1] + m[1][2] + m[2][1]
z[1][2] = m[0][2] + m[1][2] + m[2][2] + m[1][1]
z[2][0] = m[1][0] + m[2][0] + m[2][1]
z[2][1] = m[2][0] + m[2][1] + m[2][2] + m[1][1]
z[2][2] = m[2][2] + m[2][1] + m[1][2]
for i in range(3):
	for j in range(3):
		if z[i][j] % 2 == 0:
			z[i][j] = 1
		else:
			z[i][j] = 0
for i in range(3):
	for j in range(3):
		print(z[i][j], end='')
	print('')


l = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	z = list(map(int, input().split()))
	for j in range(3):
		if z[j] % 2 == 1:
			if j + 1 < 3:
				l[i][j + 1] = (l[i][j + 1] + 1) % 2
			if i + 1 < 3:
				l[i + 1][j] = (l[i + 1][j] + 1) % 2
			if j - 1 >= 0:
				l[i][j - 1] = (l[i][j - 1] + 1) % 2
			if i - 1 >= 0:
				l[i - 1][j] = (l[i - 1][j] + 1) % 2
			l[i][j] = (l[i][j] + 1) % 2
for i in l:
	print(''.join(list(map(lambda t: str(t), i))))


l = []
status = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	l.append(input().split())
for i in range(3):
	for j in range(3):
		l[i][j] = int(l[i][j])
for i in range(3):
	for j in range(3):
		if l[i][j] % 2 != 0:
			status[i][j] = status[i][j] ^ 1
			if i - 1 >= 0:
				status[i - 1][j] = status[i - 1][j] ^ 1
			if j - 1 >= 0:
				status[i][j - 1] = status[i][j - 1] ^ 1
			if i + 1 <= 2:
				status[i + 1][j] = status[i + 1][j] ^ 1
			if j + 1 <= 2:
				status[i][j + 1] = status[i][j + 1] ^ 1
for i in status:
	for j in i:
		print(j, end='')
	print()


novogrid1 = input()
novogrid1 = list(map(int, novogrid1.split()))
novogrid2 = input()
novogrid2 = list(map(int, novogrid2.split()))
novogrid3 = input()
novogrid3 = list(map(int, novogrid3.split()))
grid11 = novogrid1[0] + novogrid1[1] + novogrid2[0] + 1
grid12 = novogrid1[0] + novogrid1[1] + novogrid1[2] + novogrid2[1] + 1
grid13 = novogrid1[1] + novogrid1[2] + novogrid2[2] + 1
grid21 = novogrid2[0] + novogrid1[0] + novogrid3[0] + novogrid2[1] + 1
grid23 = novogrid2[2] + novogrid1[2] + novogrid3[2] + novogrid2[1] + 1
grid22 = novogrid1[1] + novogrid3[1] + novogrid2[0] + novogrid2[1] + novogrid2[2] + 1
grid31 = novogrid2[0] + novogrid3[1] + novogrid3[0] + 1
grid32 = novogrid3[0] + novogrid3[1] + novogrid3[2] + novogrid2[1] + 1
grid33 = novogrid2[2] + novogrid3[2] + novogrid3[1] + 1
print(grid11 % 2, grid12 % 2, grid13 % 2, sep='')
print(grid21 % 2, grid22 % 2, grid23 % 2, sep='')
print(grid31 % 2, grid32 % 2, grid33 % 2, sep='')


def lit(v, x, y):
	s = v[x][y]
	if x < 2:
		s += v[x + 1][y]
	if y < 2:
		s += v[x][y + 1]
	if x > 0:
		s += v[x - 1][y]
	if y > 0:
		s += v[x][y - 1]
	return (s + 1) % 2
v = []
for i in range(3):
	v.append([i % 2 for i in list(map(int, input().strip().split()))])
for i in range(3):
	for j in range(3):
		print(lit(v, i, j), end='')
	print()


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:
		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'
grid = []
for _ in range(3):
	grid.append(list(map(int, input().split())))
n = calc(grid)
for row in n:
	print(''.join(row))


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


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

def swap(val):
	if val == 0:
		val = 1
	else:
		val = 0
	return val
copy = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]

def solve(arr):
	for i in range(len(arr)):
		for j in range(len(arr)):
			if arr[i][j] > 0:
				if arr[i][j] % 2 != 0:
					copy[i][j] = swap(copy[i][j])
					if j + 1 < 3:
						copy[i][j + 1] = swap(copy[i][j + 1])
					if j - 1 >= 0:
						copy[i][j - 1] = swap(copy[i][j - 1])
					if i - 1 >= 0:
						copy[i - 1][j] = swap(copy[i - 1][j])
					if i + 1 < 3:
						copy[i + 1][j] = swap(copy[i + 1][j])
	for array in copy:
		array = [str(x) for x in array]
		print(''.join(array))
solve(a)


I0 = lambda : map(int, input().split())
I1 = lambda : int(input())
I2 = lambda : list(map(int, input().split()))
l = list()
light = [[1] * 3 for i in range(3)]
for i in range(3):
	l.append(I2())
for i in range(3):
	for j in range(3):
		if l[i][j] % 2 == 1:
			light[i][j] ^= 1
			if i != 0:
				light[i - 1][j] ^= 1
			if j != 0:
				light[i][j - 1] ^= 1
			if j + 1 != 3:
				light[i][j + 1] ^= 1
			if i + 1 != 3:
				light[i + 1][j] ^= 1
for i in range(3):
	print(*light[i], sep='')


M = [list(map(int, input().split())) for i in range(3)]
M1 = [[1 for i in range(5)] for j in range(5)]
for i in range(3):
	for j in range(3):
		if M[i][j] % 2 != 0:
			if M1[i + 1][j + 1] == 0:
				M1[i + 1][j + 1] = 1
			else:
				M1[i + 1][j + 1] = 0
			if M1[i + 1][j + 2] == 0:
				M1[i + 1][j + 2] = 1
			else:
				M1[i + 1][j + 2] = 0
			if M1[i + 2][j + 1] == 0:
				M1[i + 2][j + 1] = 1
			else:
				M1[i + 2][j + 1] = 0
			if M1[i + 1][j] == 0:
				M1[i + 1][j] = 1
			else:
				M1[i + 1][j] = 0
			if M1[i][j + 1] == 0:
				M1[i][j + 1] = 1
			else:
				M1[i][j + 1] = 0
M2 = []
for i in range(1, 4):
	S = ''
	for j in range(1, 4):
		S = S + str(M1[i][j])
	print(S)


import sys

def rn(x, y):
	return x >= 0 and x < 3 and (y >= 0) and (y < 3)
grid = []
state = []
for line in sys.stdin:
	grid.append(list(map(int, line.split())))
	state.append([0] * 3)
dx = [-1, 0, 0, 1]
dy = [0, 1, -1, 0]
for i in range(3):
	for j in range(3):
		for k in range(4):
			if rn(i + dx[k], j + dy[k]):
				if grid[i][j] & 1:
					state[i + dx[k]][j + dy[k]] += 1
for i in range(3):
	for j in range(3):
		if state[i][j] + grid[i][j] & 1:
			print('0', end='')
		else:
			print('1', end='')
	print('')


res = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
arr = []

def tog(i, j):
	if res[i][j] == 1:
		res[i][j] = 0
	else:
		res[i][j] = 1
for i in range(3):
	x = list(map(int, input().split()))
	arr.append(x)
for i in range(3):
	for j in range(3):
		if arr[i][j] != 0 and arr[i][j] % 2 != 0:
			if i == 0 and j == 0:
				tog(i, j)
				tog(i, j + 1)
				tog(i + 1, j)
			elif i == 0 and j == 1:
				tog(i, j)
				tog(i, j - 1)
				tog(i, j + 1)
				tog(i + 1, j)
			elif i == 0 and j == 2:
				tog(i, j)
				tog(i + 1, j)
				tog(i, j - 1)
			elif i == 1 and j == 0:
				tog(i, j)
				tog(i, j + 1)
				tog(i + 1, j)
				tog(i - 1, j)
			elif i == 1 and j == 1:
				tog(i, j)
				tog(i, j - 1)
				tog(i, j + 1)
				tog(i + 1, j)
				tog(i - 1, j)
			elif i == 1 and j == 2:
				tog(i, j)
				tog(i + 1, j)
				tog(i, j - 1)
				tog(i - 1, j)
			elif i == 2 and j == 0:
				tog(i, j)
				tog(i, j + 1)
				tog(i - 1, j)
			elif i == 2 and j == 1:
				tog(i, j)
				tog(i, j - 1)
				tog(i, j + 1)
				tog(i - 1, j)
			elif i == 2 and j == 2:
				tog(i, j)
				tog(i - 1, j)
				tog(i, j - 1)
for i in range(3):
	for j in range(3):
		print(res[i][j], end='')
	print()


def togle(s):
	if s == '0':
		return '1'
	else:
		return '0'

def convert(s):
	str1 = ''
	return str1.join(s)
inp = []
for i in range(3):
	inp.append(input().split())
lights = [['1', '1', '1'], ['1', '1', '1'], ['1', '1', '1']]
for r in range(3):
	for c in range(3):
		num = int(inp[r][c])
		if num % 2 == 1:
			lights[r][c] = togle(lights[r][c])
			if r - 1 >= 0:
				lights[r - 1][c] = togle(lights[r - 1][c])
			if r + 1 < 3:
				lights[r + 1][c] = togle(lights[r + 1][c])
			if c - 1 >= 0:
				lights[r][c - 1] = togle(lights[r][c - 1])
			if c + 1 < 3:
				lights[r][c + 1] = togle(lights[r][c + 1])
for l in lights:
	print(convert(l))


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


matrix = []
matrix.append([0, 0, 0, 0, 0])
for i in range(3):
	matrix.append([0] + [int(x) for x in input().split(' ')] + [0])
matrix.append([0, 0, 0, 0, 0])
tmp_matrix = [[0] * 5 for x in range(5)]
for i in range(1, 4):
	for j in range(1, 4):
		tmp_matrix[i][j] += matrix[i][j]
		tmp_matrix[i - 1][j] += matrix[i][j]
		tmp_matrix[i + 1][j] += matrix[i][j]
		tmp_matrix[i][j - 1] += matrix[i][j]
		tmp_matrix[i][j + 1] += matrix[i][j]
for i in range(1, 4):
	print(''.join(['0' if x % 2 > 0 else '1' for x in tmp_matrix[i][1:4]]))


s = []
ans = []
for i in range(0, 3):
	a = input()
	a = a.split(' ')
	s.append(a)
for i in range(0, 3):
	for j in range(0, 3):
		s[i][j] = int(s[i][j])
for i in range(0, 3):
	for j in range(0, 3):
		if i == 0:
			if j == 0:
				a = (s[i][j] + s[i][j + 1] + s[i + 1][j]) % 2
				if a == 0:
					ans.append(1)
				else:
					ans.append(0)
			elif j == 1:
				a = (s[i][j] + s[i][j + 1] + s[i + 1][j] + s[i][j - 1]) % 2
				if a == 0:
					ans.append(1)
				else:
					ans.append(0)
			elif j == 2:
				a = (s[i][j] + s[i][j - 1] + s[i + 1][j]) % 2
				if a == 0:
					ans.append(1)
				else:
					ans.append(0)
		elif i == 1:
			if j == 0:
				a = (s[i][j] + s[i][j + 1] + s[i + 1][j] + s[i - 1][j]) % 2
				if a == 0:
					ans.append(1)
				else:
					ans.append(0)
			elif j == 1:
				a = (s[i][j] + s[i][j + 1] + s[i + 1][j] + s[i][j - 1] + s[i - 1][j]) % 2
				if a == 0:
					ans.append(1)
				else:
					ans.append(0)
			elif j == 2:
				a = (s[i][j] + s[i + 1][j] + s[i][j - 1] + s[i - 1][j]) % 2
				if a == 0:
					ans.append(1)
				else:
					ans.append(0)
		elif i == 2:
			if j == 0:
				a = (s[i][j] + s[i][j + 1] + s[i - 1][j]) % 2
				if a == 0:
					ans.append(1)
				else:
					ans.append(0)
			elif j == 1:
				a = (s[i][j] + s[i][j + 1] + s[i - 1][j] + s[i][j - 1]) % 2
				if a == 0:
					ans.append(1)
				else:
					ans.append(0)
			elif j == 2:
				a = (s[i][j] + s[i][j - 1] + s[i - 1][j]) % 2
				if a == 0:
					ans.append(1)
				else:
					ans.append(0)
for i in range(9):
	if i == 3 or i == 6:
		print()
	print(ans[i], end='')
print()


grid = []
for _ in range(3):
	row = list(map(int, input().split(' ')))
	grid.append(row)
for i in range(3):
	for j in range(3):
		sum = grid[i][j]
		if j + 1 < 3:
			sum += grid[i][j + 1]
		if j - 1 >= 0:
			sum += grid[i][j - 1]
		if i + 1 < 3:
			sum += grid[i + 1][j]
		if i - 1 >= 0:
			sum += grid[i - 1][j]
		if sum % 2:
			print(0, end='')
		else:
			print(1, end='')
	print(end='\n')


a = []
p = []
q = []
r = []
for i in range(3):
	a += [list(map(int, input().split()))]
p.append('0') if (a[0][0] + a[0][1] + a[1][0]) % 2 == 1 else p.append('1')
p.append('0') if (a[0][0] + a[0][1] + a[0][2] + a[1][1]) % 2 == 1 else p.append('1')
p.append('0') if (a[0][2] + a[0][1] + a[1][2]) % 2 == 1 else p.append('1')
q.append('0') if (a[0][0] + a[1][0] + a[2][0] + a[1][1]) % 2 == 1 else q.append('1')
q.append('0') if (a[1][0] + a[1][1] + a[1][2] + a[0][1] + a[2][1]) % 2 == 1 else q.append('1')
q.append('0') if (a[0][2] + a[1][2] + a[2][2] + a[1][1]) % 2 == 1 else q.append('1')
r.append('0') if (a[2][0] + a[2][1] + a[1][0]) % 2 == 1 else r.append('1')
r.append('0') if (a[2][0] + a[2][1] + a[1][1] + a[2][2]) % 2 == 1 else r.append('1')
r.append('0') if (a[2][1] + a[2][2] + a[1][2]) % 2 == 1 else r.append('1')
print(''.join(p))
print(''.join(q))
print(''.join(r))


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

def changeNeighbours(arr, i, j):
	invert(arr, i, j)
	if i - 1 >= 0:
		invert(arr, i - 1, j)
	if j - 1 >= 0:
		invert(arr, i, j - 1)
	if i + 1 <= 2:
		invert(arr, i + 1, j)
	if j + 1 <= 2:
		invert(arr, i, j + 1)
ourGrid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
given = []
for i in range(3):
	given.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		if given[i][j] % 2 == 1:
			changeNeighbours(ourGrid, i, j)
for g in ourGrid:
	print(''.join(map(str, g)))


m = [[0] * 5] + [[0] + [int(x) for x in input().split(' ')] + [0] for row in range(3)] + [[0] * 5]
for i in range(1, 4):
	s = ''.join([str(sum([1, m[i - 1][j], m[i + 1][j], m[i][j], m[i][j + 1], m[i][j - 1]]) % 2) for j in range(1, 4)])
	print(s)


lights = [[1 for i in range(3)] for j in range(3)]
flips = []
for i in range(3):
	flips.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		flip = flips[i][j]
		lights[i][j] += flip
		if i + 1 < 3:
			lights[i + 1][j] += flip
		if i - 1 >= 0:
			lights[i - 1][j] += flip
		if j + 1 < 3:
			lights[i][j + 1] += flip
		if j - 1 >= 0:
			lights[i][j - 1] += flip
for i in range(3):
	for j in range(3):
		lights[i][j] %= 2
		print(lights[i][j], end='')
	print()


arr_i = [list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split()))]
arr = [[1 for x in range(3)] for y in range(3)]
arr[0][0] = (arr_i[0][0] + arr_i[0][1] + arr_i[1][0] + 1) % 2
arr[0][1] = (arr_i[0][0] + arr_i[0][1] + arr_i[0][2] + arr_i[1][1] + 1) % 2
arr[0][2] = (arr_i[0][1] + arr_i[0][2] + arr_i[1][2] + 1) % 2
arr[1][0] = (arr_i[0][0] + arr_i[1][0] + arr_i[1][1] + arr_i[2][0] + 1) % 2
arr[1][1] = (arr_i[0][1] + arr_i[1][0] + arr_i[1][1] + arr_i[1][2] + arr_i[2][1] + 1) % 2
arr[1][2] = (arr_i[0][2] + arr_i[1][1] + arr_i[1][2] + arr_i[2][2] + 1) % 2
arr[2][0] = (arr_i[1][0] + arr_i[2][0] + arr_i[2][1] + 1) % 2
arr[2][1] = (arr_i[1][1] + arr_i[2][0] + arr_i[2][1] + arr_i[2][2] + 1) % 2
arr[2][2] = (arr_i[1][2] + arr_i[2][1] + arr_i[2][2] + 1) % 2
for i in range(3):
	for j in range(3):
		print(arr[i][j], end='')
	print()


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)


light_state = [['1', '1', '1'] for _ in range(3)]
button_press = [[int(x) for x in input().strip().split()] for _ in range(3)]

def toggle(state):
	return '1' if state == '0' else '0'
for i in range(3):
	for j in range(3):
		if button_press[i][j] % 2 == 1:
			light_state[i][j] = toggle(light_state[i][j])
			for x in range(i - 1, i + 2, 2):
				if 0 <= x <= 2:
					light_state[x][j] = toggle(light_state[x][j])
			for y in range(j - 1, j + 2, 2):
				if 0 <= y <= 2:
					light_state[i][y] = toggle(light_state[i][y])
for l in light_state:
	print(''.join(l))


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

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

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


lines = list()
for i in range(3):
	lines.append([1 for i in range(3)])
line = str(input()).split()
line = [int(fx) % 2 for fx in line]
if line[0] == 1:
	lines[0][0] += 1
	lines[0][1] += 1
	lines[1][0] += 1
if line[1] == 1:
	lines[0][0] += 1
	lines[0][1] += 1
	lines[0][2] += 1
	lines[1][1] += 1
if line[2] == 1:
	lines[0][1] += 1
	lines[0][2] += 1
	lines[1][2] += 1
line = str(input()).split()
line = [int(fx) % 2 for fx in line]
if line[0] == 1:
	lines[1][0] += 1
	lines[1][1] += 1
	lines[0][0] += 1
	lines[2][0] += 1
if line[1] == 1:
	lines[1][0] += 1
	lines[1][1] += 1
	lines[1][2] += 1
	lines[0][1] += 1
	lines[2][1] += 1
if line[2] == 1:
	lines[1][1] += 1
	lines[1][2] += 1
	lines[0][2] += 1
	lines[2][2] += 1
line = str(input()).split()
line = [int(fx) % 2 for fx in line]
if line[0] == 1:
	lines[2][0] += 1
	lines[2][1] += 1
	lines[1][0] += 1
if line[1] == 1:
	lines[2][0] += 1
	lines[2][1] += 1
	lines[2][2] += 1
	lines[1][1] += 1
if line[2] == 1:
	lines[2][1] += 1
	lines[2][2] += 1
	lines[1][2] += 1
for line in lines:
	print(''.join([str(fx % 2) for fx in line]))


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


from collections import defaultdict, deque, Counter, OrderedDict
import threading, sys
from math import gcd
dx = [0, 0, 1, -1, 0]
dy = [1, -1, 0, 0, 0]

def main():
	a = [[i % 2 for i in map(int, input().split())] for j in range(3)]
	ans = [[1 for i in range(3)] for j in range(3)]
	for i in range(3):
		for j in range(3):
			if a[i][j]:
				for k in range(5):
					if 0 <= i + dx[k] < 3 and 0 <= j + dy[k] < 3:
						ans[i + dx[k]][j + dy[k]] = 1 - ans[i + dx[k]][j + dy[k]]
	for i in ans:
		print(''.join(map(str, i)))
main()


n = list(map(int, input().split()))
n.extend(list(map(int, input().split())))
n.extend(list(map(int, input().split())))
p1 = str((n[0] + n[1] + n[3] + 1) % 2) + str((n[0] + n[1] + n[4] + n[2] + 1) % 2) + str((n[1] + n[2] + n[5] + 1) % 2)
p2 = str((n[0] + n[4] + n[3] + n[6] + 1) % 2) + str((n[3] + n[1] + n[4] + n[5] + n[7] + 1) % 2) + str((n[4] + n[2] + n[5] + n[8] + 1) % 2)
p3 = str((n[3] + n[6] + n[7] + 1) % 2) + str((n[4] + n[6] + n[7] + n[8] + 1) % 2) + str((n[7] + n[8] + n[5] + 1) % 2)
print(p1 + '\n' + p2 + '\n' + p3)


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


c = []
for i in range(3):
	a = input().split()
	a = list(map(int, a))
	c.append(a)
for i in range(3):
	for j in range(3):
		s = -c[i][j]
		for ki in range(max(0, i - 1), min(3, i + 2)):
			s += c[ki][j]
		for kj in range(max(0, j - 1), min(3, j + 2)):
			s += c[i][kj]
		d = 1 - s % 2
		print(d, end='')
	print('')


def tgl(n):
	n = 1 - n
	return n
m = [[0 for i in range(5)] for i in range(5)]
f = [[1 for i in range(5)] for i in range(5)]
for i in range(1, 4):
	m[i][1:4] = list(map(int, input().split(' ')))
for i in range(1, 4):
	for j in range(1, 4):
		if m[i][j] % 2:
			f[i][j] = tgl(f[i][j])
			f[i + 1][j] = tgl(f[i + 1][j])
			f[i - 1][j] = tgl(f[i - 1][j])
			f[i][j + 1] = tgl(f[i][j + 1])
			f[i][j - 1] = tgl(f[i][j - 1])
for i in range(1, 4):
	for j in range(1, 4):
		print(f[i][j], end='')
	print()


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


def flip(index1, index2, array):
	if array[index1][index2] == 0:
		array[index1][index2] = 1
	else:
		array[index1][index2] = 0
	for i in [-1, 1]:
		if index1 + i < 0 or index1 + i > 2:
			continue
		if array[index1 + i][index2] == 0:
			array[index1 + i][index2] = 1
		else:
			array[index1 + i][index2] = 0
	for j in [-1, 1]:
		if index2 + j < 0 or index2 + j > 2:
			continue
		if array[index1][index2 + j] == 0:
			array[index1][index2 + j] = 1
		else:
			array[index1][index2 + j] = 0
	return array

def main():
	gris = []
	for i in range(3):
		gris.append([])
		for j in range(3):
			gris[i].append(1)
	but = []
	for i in range(3):
		but.append([])
		string = input()
		string = string.split(' ')
		for j in range(3):
			but[i].append(int(string[j]))
	for i in range(3):
		for j in range(3):
			if but[i][j] % 2 == 1:
				gris = flip(i, j, gris)
	for i in range(3):
		for j in range(3):
			print(gris[i][j], end='')
		print()
	return
main()


state = [[1] * 3 for _ in range(3)]
presses = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
	for j in range(3):
		if presses[i][j] % 2 == 1:
			for (x, y) in [(0, 0), (0, -1), (0, 1), (-1, 0), (1, 0)]:
				if 0 <= i + x < 3 and 0 <= j + y < 3:
					state[i + x][j + y] = 1 - state[i + x][j + y]
for row in state:
	print(''.join(map(str, row)))


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


while True:
	try:

		class Game:

			def __init__(self, mtrx=[], tmtrx=[]):
				self.mtrx = []
				self.tmtrx = [[1 for j in range(3)] for i in range(3)]

			def inputt(self):
				for i in range(3):
					mx = list(map(int, input().split()))
					self.mtrx.append(mx)
					del mx

			def solve(self):
				x = [-1, 1, 0, 0, 0]
				y = [0, 0, 1, -1, 0]
				for i in range(3):
					for j in range(3):
						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):
								if self.mtrx[i][j] % 2 != 0:
									if self.tmtrx[i + x[k]][j + y[k]] == 0:
										self.tmtrx[i + x[k]][j + y[k]] = 1
									else:
										self.tmtrx[i + x[k]][j + y[k]] = 0

			def print_res(self):
				t = str()
				for i in range(3):
					for j in range(3):
						t = t + str(self.tmtrx[i][j])
					print(t)
					del t
					t = str()
		if __name__ == '__main__':
			obj = Game()
			obj.inputt()
			obj.solve()
			obj.print_res()
	except EOFError:
		break


A = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
	s = input()
	s = s.split()
	for j in range(3):
		s[j] = int(s[j])
	A[i][0] = s[0]
	A[i][1] = s[1]
	A[i][2] = s[2]
tots = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for k in range(3):
	for l in range(3):
		if k == 0 and l == 0:
			tots[k][l] = A[k][l] + A[k][l + 1] + A[k + 1][l]
		elif k == 0 and l == 2:
			tots[k][l] = A[k][l] + A[k][l - 1] + A[k + 1][l]
		elif k == 2 and l == 0:
			tots[k][l] = A[k][l] + A[k - 1][l] + A[k][l + 1]
		elif k == 2 and l == 2:
			tots[k][l] = A[k][l] + A[k][l - 1] + A[k - 1][l]
		elif k == 0 and l == 1:
			tots[k][l] = A[k][l] + A[1][1] + A[0][0] + A[0][2]
		elif k == 1 and l == 2:
			tots[k][l] = A[k][l] + A[1][1] + A[2][2] + A[0][2]
		elif k == 2 and l == 1:
			tots[k][l] = A[k][l] + A[1][1] + A[2][0] + A[2][2]
		elif k == 1 and l == 0:
			tots[k][l] = A[k][l] + A[1][1] + A[0][0] + A[2][0]
		elif k == 1 and l == 1:
			tots[k][l] = A[k][l] + A[1][0] + A[0][1] + A[1][2] + A[2][1]
m = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for a in range(3):
	for b in range(3):
		if tots[a][b] % 2 != 0:
			m[a][b] = 0
for t in range(3):
	for r in range(3):
		print(m[t][r], end='')
	print()


y = [1, 1, 1, 1, 1, 1, 1, 1, 1]
x = [1, 1, 1, 1, 1, 1, 1, 1, 1]
(x[0], x[1], x[2]) = map(int, input().split())
(x[3], x[4], x[5]) = map(int, input().split())
(x[6], x[7], x[8]) = map(int, input().split())
for i in range(0, 9):
	if i == 0:
		if int(x[i]) % 2 != 0:
			y[i] = int(not y[i])
			y[i + 1] = int(not y[i + 1])
			y[i + 3] = int(not y[i + 3])
		elif int(x[i]) % 2 == 0:
			continue
	elif i == 1:
		if int(x[i]) % 2 != 0:
			y[i] = int(not y[i])
			y[i + 1] = int(not y[i + 1])
			y[i - 1] = int(not y[i - 1])
			y[i + 3] = int(not y[i + 3])
		elif int(x[i]) % 2 == 0:
			continue
	elif i == 2:
		if int(x[i]) % 2 != 0:
			y[i] = int(not y[i])
			y[i - 1] = int(not y[i - 1])
			y[i + 3] = int(not y[i + 3])
		elif int(x[i]) % 2 == 0:
			continue
	elif i == 3:
		if int(x[i]) % 2 != 0:
			y[i] = int(not y[i])
			y[i + 1] = int(not y[i + 1])
			y[i + 3] = int(not y[i + 3])
			y[i - 3] = int(not y[i - 3])
		elif int(x[i]) % 2 == 0:
			continue
	elif i == 4:
		if int(x[i]) % 2 != 0:
			y[i] = int(not y[i])
			y[i + 1] = int(not y[i + 1])
			y[i - 1] = int(not y[i - 1])
			y[i + 3] = int(not y[i + 3])
			y[i - 3] = int(not y[i - 3])
		elif int(x[i]) % 2 == 0:
			continue
	elif i == 5:
		if int(x[i]) % 2 != 0:
			y[i] = int(not y[i])
			y[i - 1] = int(not y[i - 1])
			y[i + 3] = int(not y[i + 3])
			y[i - 3] = int(not y[i - 3])
		elif int(x[i]) % 2 == 0:
			continue
	elif i == 6:
		if int(x[i]) % 2 != 0:
			y[i] = int(not y[i])
			y[i + 1] = int(not y[i + 1])
			y[i - 3] = int(not y[i - 3])
		elif int(x[i]) % 2 == 0:
			continue
	elif i == 7:
		if int(x[i]) % 2 != 0:
			y[i] = int(not y[i])
			y[i + 1] = int(not y[i + 1])
			y[i - 1] = int(not y[i - 1])
			y[i - 3] = int(not y[i - 3])
		elif int(x[i]) % 2 == 0:
			continue
	elif i == 8:
		if int(x[i]) % 2 != 0:
			y[i] = int(not y[i])
			y[i - 1] = int(not y[i - 1])
			y[i - 3] = int(not y[i - 3])
		elif int(x[i]) % 2 == 0:
			continue
for i in range(0, 3):
	print(y[i], end='')
print('')
for i in range(3, 6):
	print(y[i], end='')
print('')
for i in range(6, 9):
	print(y[i], end='')


mat = [list(map(int, input().split())) for i in range(3)]
switches = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	for j in range(3):
		if mat[i][j] % 2 == 1:
			switches[i][j] = 1 - switches[i][j]
			if i > 0:
				switches[i - 1][j] = 1 - switches[i - 1][j]
			if i < 2:
				switches[i + 1][j] = 1 - switches[i + 1][j]
			if j > 0:
				switches[i][j - 1] = 1 - switches[i][j - 1]
			if j < 2:
				switches[i][j + 1] = 1 - switches[i][j + 1]
for i in switches:
	print(*i, sep='')


data = []
for _ in range(3):
	data.append(list(map(lambda v: int(v) % 2, input().split())))
result = [[1 - data[i][j] for j in range(3)] for i in range(3)]
result[0][0] += data[0][1] + data[1][0]
result[0][1] += data[0][0] + data[0][2] + data[1][1]
result[0][2] += data[0][1] + data[1][2]
result[1][0] += data[0][0] + data[2][0] + data[1][1]
result[1][1] += data[0][1] + data[2][1] + data[1][0] + data[1][2]
result[1][2] += data[0][2] + data[2][2] + data[1][1]
result[2][0] += data[1][0] + data[2][1]
result[2][1] += data[2][0] + data[2][2] + data[1][1]
result[2][2] += data[2][1] + data[1][2]
for row in result:
	print(''.join((str(v % 2) for v in row)))


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

def total(arr, i, j):
	valid = list(range(3))
	ans = arr[i][j]
	if i + 1 in valid:
		ans += arr[i + 1][j]
	if j + 1 in valid:
		ans += arr[i][j + 1]
	if i - 1 in valid:
		ans += arr[i - 1][j]
	if j - 1 in valid:
		ans += arr[i][j - 1]
	return ans
for i in range(3):
	for j in range(3):
		new_arr[i][j] = total(arr, i, j)
for i in range(3):
	for j in range(3):
		if new_arr[i][j] % 2 == 0:
			new_arr[i][j] = 1
		else:
			new_arr[i][j] = 0
		print(new_arr[i][j], end='')
	print('')


li = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
pattern = [list(map(int, input().split())) for i in range(3)]
for i in range(3):
	for j in range(3):
		if pattern[i][j] % 2 != 0:
			if i == 0:
				if j == 0:
					li[i][j] ^= 1
					li[i][j + 1] ^= 1
					li[i + 1][j] ^= 1
				elif j == 1:
					li[i][j - 1] ^= 1
					li[i][j] ^= 1
					li[i][j + 1] ^= 1
					li[i + 1][j] ^= 1
				elif j == 2:
					li[i][j] ^= 1
					li[i][j - 1] ^= 1
					li[i + 1][j] ^= 1
			elif i == 1:
				if j == 0:
					li[i - 1][j] ^= 1
					li[i][j] ^= 1
					li[i + 1][j] ^= 1
					li[i][j + 1] ^= 1
				elif j == 1:
					li[i - 1][j] ^= 1
					li[i][j - 1] ^= 1
					li[i][j] ^= 1
					li[i][j + 1] ^= 1
					li[i + 1][j] ^= 1
				elif j == 2:
					li[i - 1][j] ^= 1
					li[i][j] ^= 1
					li[i][j - 1] ^= 1
					li[i + 1][j] ^= 1
			elif i == 2:
				if j == 0:
					li[i - 1][j] ^= 1
					li[i][j] ^= 1
					li[i][j + 1] ^= 1
				elif j == 1:
					li[i][j - 1] ^= 1
					li[i][j] ^= 1
					li[i][j + 1] ^= 1
					li[i - 1][j] ^= 1
				elif j == 2:
					li[i][j] ^= 1
					li[i][j - 1] ^= 1
					li[i - 1][j] ^= 1
for i in range(3):
	for j in range(3):
		print(li[i][j], end='')
	print('')


m = [[0] * 3 for i in range(3)]
inp = [list(map(int, input().split())) for i in '234']

def valid(i, j):
	return i >= 0 and j >= 0 and (i < 3) and (j < 3)
for i in range(3):
	for j in range(3):
		offs = ((0, 1), (0, -1), (1, 0), (-1, 0), (0, 0))
		for (x, y) in offs:
			k = i + x
			l = j + y
			if valid(k, l):
				m[k][l] += inp[i][j]
for i in range(3):
	for j in range(3):
		print(int(m[i][j] % 2 == 0), end='')
	print()


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


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


ans = []
for i in range(3):
	x = [int(i) for i in input().strip().split()]
	ans.append(x)
a = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
a[0][0] = (ans[0][0] + ans[1][0] + ans[0][1]) % 2
a[0][1] = (ans[0][1] + ans[1][1] + ans[0][0] + ans[0][2]) % 2
a[0][2] = (ans[0][2] + ans[0][1] + ans[1][2]) % 2
a[1][0] = (ans[1][0] + ans[1][1] + ans[0][0] + ans[2][0]) % 2
a[1][1] = (ans[1][0] + ans[1][1] + ans[1][2] + ans[0][1] + ans[2][1]) % 2
a[1][2] = (ans[1][2] + ans[1][1] + ans[0][2] + ans[2][2]) % 2
a[2][0] = (ans[2][0] + ans[2][1] + ans[1][0]) % 2
a[2][1] = (ans[2][1] + ans[2][0] + ans[2][2] + ans[1][1]) % 2
a[2][2] = (ans[2][2] + ans[2][1] + ans[1][2]) % 2
for i in range(3):
	for j in range(3):
		if a[i][j] == 1:
			a[i][j] = 0
		else:
			a[i][j] = 1
for i in range(3):
	print(''.join(map(str, a[i])))


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


row1 = list(map(int, list(input().split())))
row2 = list(map(int, list(input().split())))
row3 = list(map(int, list(input().split())))
f = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]

def switch(r, c):

	def change(num):
		if num == 0:
			num = 1
		else:
			num = 0
		return num
	f[r][c] = change(f[r][c])
	f[r - 1][c] = change(f[r - 1][c])
	f[r + 1][c] = change(f[r + 1][c])
	f[r][c - 1] = change(f[r][c - 1])
	f[r][c + 1] = change(f[r][c + 1])
for p in [0, 1, 2]:
	if row1[p] % 2 == 1:
		switch(1, p + 1)
for p in [0, 1, 2]:
	if row2[p] % 2 == 1:
		switch(2, p + 1)
for p in [0, 1, 2]:
	if row3[p] % 2 == 1:
		switch(3, p + 1)
print(str(f[1][1]) + str(f[1][2]) + str(f[1][3]))
print(str(f[2][1]) + str(f[2][2]) + str(f[2][3]))
print(str(f[3][1]) + str(f[3][2]) + str(f[3][3]))


l = []
for i in range(3):
	l.append([int(x) for x in input().split()])
if (l[0][0] + l[0][1] + l[1][0]) % 2 == 1:
	print(0, end='')
else:
	print(1, end='')
if (l[0][0] + l[0][1] + l[1][1] + l[0][2]) % 2 == 1:
	print(0, end='')
else:
	print(1, end='')
if (l[0][1] + l[0][2] + l[1][2]) % 2 == 1:
	print(0, end='')
else:
	print(1, end='')
print()
if (l[0][0] + l[2][0] + l[1][1] + l[1][0]) % 2 == 1:
	print(0, end='')
else:
	print(1, end='')
if (l[1][0] + l[0][1] + l[1][2] + l[2][1] + l[1][1]) % 2 == 1:
	print(0, end='')
else:
	print(1, end='')
if (l[1][1] + l[0][2] + l[1][2] + l[2][2]) % 2 == 1:
	print(0, end='')
else:
	print(1, end='')
print()
if (l[2][0] + l[1][0] + l[2][1]) % 2 == 1:
	print(0, end='')
else:
	print(1, end='')
if (l[2][0] + l[2][1] + l[2][2] + l[1][1]) % 2 == 1:
	print(0, end='')
else:
	print(1, end='')
if (l[2][2] + l[2][1] + l[1][2]) % 2 == 1:
	print(0, end='')
else:
	print(1, end='')


def compute(mat2, mat1):
	for i in range(3):
		for j in range(3):
			if mat2[i][j] > 0:
				lights(mat1, i, j, mat2[i][j])

def result(a, b):
	if a == 1:
		if b % 2 == 0:
			return 1
		else:
			return 0
	elif b % 2 == 0:
		return 0
	else:
		return 1

def lights(mat1, i, j, val):
	mat1[i][j] = result(mat1[i][j], val)
	if i - 1 >= 0:
		mat1[i - 1][j] = result(mat1[i - 1][j], val)
	if i + 1 <= 2:
		mat1[i + 1][j] = result(mat1[i + 1][j], val)
	if j + 1 <= 2:
		mat1[i][j + 1] = result(mat1[i][j + 1], val)
	if j - 1 >= 0:
		mat1[i][j - 1] = result(mat1[i][j - 1], val)
mat1 = []
for i in range(3):
	a = []
	for j in range(3):
		a.append(1)
	mat1.append(a)
a = []
for i in range(3):
	a.append([int(j) for j in input().split()])
compute(a, mat1)
for i in range(3):
	for j in range(3):
		print(mat1[i][j], end='')
	print()


l = []
for x in range(3):
	l.extend(list(map(int, input().split())))
print([1, 0][(l[0] + l[1] + l[3]) % 2], [1, 0][(l[0] + l[1] + l[2] + l[4]) % 2], [1, 0][(l[1] + l[2] + l[5]) % 2], sep='')
print([1, 0][(l[0] + l[3] + l[6] + l[4]) % 2], [1, 0][(l[1] + l[3] + l[4] + l[5] + l[7]) % 2], [1, 0][(l[2] + l[4] + l[5] + l[8]) % 2], sep='')
print([1, 0][(l[3] + l[7] + l[6]) % 2], [1, 0][(l[4] + l[6] + l[7] + l[8]) % 2], [1, 0][(l[5] + l[7] + l[8]) % 2], sep='')


table = [[0] * 5] + [[0] + list(map(int, input().split())) + [0] for i in range(3)]
table += [[0] * 5]
for i in range(1, 4):
	for j in range(1, 4):
		print((table[i][j] + 1 + table[i][j - 1] + table[i][j + 1] + table[i - 1][j] + table[i + 1][j]) % 2, end='')
	print()


state = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
lights = [[int(x) for x in input().split()], [int(x) for x in input().split()], [int(x) for x in input().split()]]
if lights[0][0] % 2 != 0:
	state[0][0] = 1 if state[0][0] == 0 else 0
	state[0][1] = 1 if state[0][1] == 0 else 0
	state[1][0] = 1 if state[1][0] == 0 else 0
if lights[0][1] % 2 != 0:
	state[0][0] = 1 if state[0][0] == 0 else 0
	state[0][1] = 1 if state[0][1] == 0 else 0
	state[1][1] = 1 if state[1][1] == 0 else 0
	state[0][2] = 1 if state[0][2] == 0 else 0
if lights[0][2] % 2 != 0:
	state[0][2] = 1 if state[0][2] == 0 else 0
	state[0][1] = 1 if state[0][1] == 0 else 0
	state[1][2] = 1 if state[1][2] == 0 else 0
if lights[1][0] % 2 != 0:
	state[1][0] = 1 if state[1][0] == 0 else 0
	state[0][0] = 1 if state[0][0] == 0 else 0
	state[2][0] = 1 if state[2][0] == 0 else 0
	state[1][1] = 1 if state[1][1] == 0 else 0
if lights[1][1] % 2 != 0:
	state[0][1] = 1 if state[0][1] == 0 else 0
	state[1][1] = 1 if state[1][1] == 0 else 0
	state[1][0] = 1 if state[1][0] == 0 else 0
	state[1][2] = 1 if state[1][2] == 0 else 0
	state[2][1] = 1 if state[2][1] == 0 else 0
if lights[1][2] % 2 != 0:
	state[1][2] = 1 if state[1][2] == 0 else 0
	state[0][2] = 1 if state[0][2] == 0 else 0
	state[2][2] = 1 if state[2][2] == 0 else 0
	state[1][1] = 1 if state[1][1] == 0 else 0
if lights[2][0] % 2 != 0:
	state[2][0] = 1 if state[2][0] == 0 else 0
	state[2][1] = 1 if state[2][1] == 0 else 0
	state[1][0] = 1 if state[1][0] == 0 else 0
if lights[2][1] % 2 != 0:
	state[2][0] = 1 if state[2][0] == 0 else 0
	state[2][1] = 1 if state[2][1] == 0 else 0
	state[1][1] = 1 if state[1][1] == 0 else 0
	state[2][2] = 1 if state[2][2] == 0 else 0
if lights[2][2] % 2 != 0:
	state[2][2] = 1 if state[2][2] == 0 else 0
	state[2][1] = 1 if state[2][1] == 0 else 0
	state[1][2] = 1 if state[1][2] == 0 else 0
print(''.join(map(str, state[0])))
print(''.join(map(str, state[1])))
print(''.join(map(str, state[2])))


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


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] = '0'
			else:
				l[indx1][indx2] = '1'
			if indx2 + 1 in [0, 1, 2]:
				if l[indx1][indx2 + 1] == '1':
					l[indx1][indx2 + 1] = '0'
				else:
					l[indx1][indx2 + 1] = '1'
			if indx2 - 1 in [0, 1, 2]:
				if l[indx1][indx2 - 1] == '1':
					l[indx1][indx2 - 1] = '0'
				else:
					l[indx1][indx2 - 1] = '1'
			if indx1 + 1 in [0, 1, 2]:
				if l[indx1 + 1][indx2] == '1':
					l[indx1 + 1][indx2] = '0'
				else:
					l[indx1 + 1][indx2] = '1'
			if indx1 - 1 in [0, 1, 2]:
				if l[indx1 - 1][indx2] == '1':
					l[indx1 - 1][indx2] = '0'
				else:
					l[indx1 - 1][indx2] = '1'
for t in l:
	for tt in t:
		print(tt, end='')
	print('')


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


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)


def switch(v: int, d: int):
	new_v = (v + d) % 2
	return new_v

def get_neighbors(r: int, c: int, size=3):
	neighbors = [(r, c)]
	if r > 0:
		neighbors.append((r - 1, c))
	if r < size - 1:
		neighbors.append((r + 1, c))
	if c > 0:
		neighbors.append((r, c - 1))
	if c < size - 1:
		neighbors.append((r, c + 1))
	return neighbors
grid = [[1 for _ in range(3)] for _ in range(3)]
counts = [[None for _ in range(3)] for _ in range(3)]
counts[0] = list(map(int, input().split()))
counts[1] = list(map(int, input().split()))
counts[2] = list(map(int, input().split()))
for r in range(3):
	for c in range(3):
		for (i, j) in get_neighbors(r, c):
			grid[i][j] = switch(grid[i][j], counts[r][c])
for r in range(3):
	print(''.join(map(str, grid[r])))


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


mat = []
for i in range(3):
	mat.append(list(map(int, input().split())))
for i in mat:
	i.insert(0, 0)
	i.append(0)
mat.insert(0, [0, 0, 0, 0, 0])
mat.append([0, 0, 0, 0, 0])
ans = []
for i in range(1, 4):
	temp = []
	for j in range(1, 4):
		temp.append(str(1 - (mat[i][j] + mat[i - 1][j] + mat[i + 1][j] + mat[i][j - 1] + mat[i][j + 1]) % 2))
	ans.append(temp)
for i in ans:
	print(''.join(i))


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


m = [[1 for i in range(3)] for _ in range(3)]
pressed = []
for _ in range(3):
	pressed.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		cnt = pressed[i][j]
		if i - 1 >= 0:
			cnt += pressed[i - 1][j]
		if j + 1 < 3:
			cnt += pressed[i][j + 1]
		if i + 1 < 3:
			cnt += pressed[i + 1][j]
		if j - 1 >= 0:
			cnt += pressed[i][j - 1]
		if cnt % 2 == 1:
			m[i][j] = 1 - m[i][j]
for i in range(3):
	for j in range(3):
		print(m[i][j], end='')
	print()


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)
	ans.append(res)
	res = []
for i in ans:
	print(*i, sep='')


def adjacent_index(i, j):
	index = []
	if i > 0:
		index.append((i - 1, j))
	if i + 1 < 3:
		index.append((i + 1, j))
	if j > 0:
		index.append((i, j - 1))
	if j + 1 < 3:
		index.append((i, j + 1))
	return index
a = [[1 for i in range(3)] for i in range(3)]
for i in range(3):
	element = list(map(int, input().split()))
	for j in range(3):
		a[i][j] = element[j]
res = [[1 for i in range(3)] for j in range(3)]
for i in range(3):
	for j in range(3):
		if a[i][j] != 0 and a[i][j] % 2 != 0:
			if res[i][j] == 0:
				res[i][j] = 1
			else:
				res[i][j] = 0
			index = adjacent_index(i, j)
			for k in index:
				if res[k[0]][k[1]] == 1:
					res[k[0]][k[1]] = 0
				else:
					res[k[0]][k[1]] = 1
for i in range(3):
	for j in range(3):
		print(res[i][j], end='')
	print()


import sys
lights = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]

def toggle(i, j):
	if i >= 0 and i <= 2 and (j >= 0) and (j <= 2):
		if lights[i][j] == 0:
			lights[i][j] = 1
		else:
			lights[i][j] = 0
i_lights = []
for _ in range(3):
	l = list(map(int, input().split()))
	i_lights.append(l)
for i in range(3):
	for j in range(3):
		for k in range(i_lights[i][j]):
			toggle(i, j)
			toggle(i, j + 1)
			toggle(i, j - 1)
			toggle(i + 1, j)
			toggle(i - 1, j)
for i in range(3):
	for j in range(3):
		sys.stdout.write(str(lights[i][j]))
	sys.stdout.write('\n')


initial = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
matrix = []
for j in range(3):
	row = [i for i in map(int, input().split())]
	matrix.append(row)
for i in range(3):
	for j in range(3):
		if matrix[i][j] % 2 == 1:
			initial[i][j] = abs(initial[i][j] - 1)
			if i - 1 >= 0:
				initial[i - 1][j] = abs(initial[i - 1][j] - 1)
			if j - 1 >= 0:
				initial[i][j - 1] = abs(initial[i][j - 1] - 1)
			if i + 1 < 3:
				initial[i + 1][j] = abs(initial[i + 1][j] - 1)
			if j + 1 < 3:
				initial[i][j + 1] = abs(initial[i][j + 1] - 1)
for i in range(3):
	for j in range(3):
		print(initial[i][j], end='')
	print('\n', end='')


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


pressed = [[0 for i in range(5)] for j in range(5)]
for i in range(1, 4):
	a = list(map(int, input().split()))
	for j in range(3):
		pressed[i][j + 1] = a[j]
for i in range(1, 4):
	for j in range(1, 4):
		cnt = pressed[i][j] + pressed[i - 1][j] + pressed[i][j + 1] + pressed[i + 1][j] + pressed[i][j - 1]
		if cnt % 2 == 1:
			print(0, end='')
		else:
			print(1, end='')
	print()


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


l = []
for _ in range(3):
	l.append([int(x) for x in input().split()])
g = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
	for j in range(3):
		if i + 1 <= 2:
			g[i + 1][j] += l[i][j]
		if i - 1 >= 0:
			g[i - 1][j] += l[i][j]
		if j + 1 <= 2:
			g[i][j + 1] += l[i][j]
		if j - 1 >= 0:
			g[i][j - 1] += l[i][j]
		g[i][j] += l[i][j]
ans = ''
for p in range(3):
	if p > 0:
		ans += '\n'
	for q in range(3):
		if g[p][q] % 2 == 0:
			ans += '1'
		else:
			ans += '0'
print(ans)


matrix = []
for i in range(3):
	x = [int(i) for i in input().split()]
	matrix.append(x)
new = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
	for j in range(3):
		if matrix[i][j] % 2 == 1:
			new[i][j] += 1
			if i == 0:
				if j == 0:
					new[i][j + 1] += 1
					new[i + 1][j] += 1
				elif j == 1:
					new[i][j + 1] += 1
					new[i + 1][j] += 1
					new[i][j - 1] += 1
				elif j == 2:
					new[i][j - 1] += 1
					new[i + 1][j] += 1
			elif i == 1:
				if j == 0:
					new[i][j + 1] += 1
					new[i + 1][j] += 1
					new[i - 1][j] += 1
				elif j == 1:
					new[i][j + 1] += 1
					new[i + 1][j] += 1
					new[i][j - 1] += 1
					new[i - 1][j] += 1
				elif j == 2:
					new[i][j - 1] += 1
					new[i + 1][j] += 1
					new[i - 1][j] += 1
			elif i == 2:
				if j == 0:
					new[i - 1][j] += 1
					new[i][j + 1] += 1
				elif j == 1:
					new[i - 1][j] += 1
					new[i][j + 1] += 1
					new[i][j - 1] += 1
				elif j == 2:
					new[i - 1][j] += 1
					new[i][j - 1] += 1
for i in range(3):
	for j in range(3):
		if new[i][j] % 2 == 0:
			print(1, end='')
		else:
			print(0, end='')
	print()


def ss(a, z):
	if x[a][z] == 0:
		x[a][z] = 1
	else:
		x[a][z] = 0
a = -1
x = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
lst = [[int(t) for t in input().split()] for i in range(3)]
for i in lst:
	a += 1
	z = -1
	for b in i:
		z += 1
		if b % 2 != 0:
			ss(a, z)
			if z - 1 > -1:
				ss(a, z - 1)
			if z + 1 < 3:
				ss(a, z + 1)
			if a - 1 > -1:
				ss(a - 1, z)
			if a + 1 < 3:
				ss(a + 1, z)
for y in x:
	for e in y:
		print(e, end='')
	print()


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

def is_valid_index(index):
	return index >= 0 and index <= 2

def toggle_lights(row, col, toggle):
	matrix[row][col] = 0 if matrix[row][col] == 1 and toggle == 1 or (matrix[row][col] == 0 and toggle == 0) else 1
	if is_valid_index(row - 1):
		matrix[row - 1][col] = 0 if matrix[row - 1][col] == 1 and toggle == 1 or (matrix[row - 1][col] == 0 and toggle == 0) else 1
	if is_valid_index(row + 1):
		matrix[row + 1][col] = 0 if matrix[row + 1][col] == 1 and toggle == 1 or (matrix[row + 1][col] == 0 and toggle == 0) else 1
	if is_valid_index(col - 1):
		matrix[row][col - 1] = 0 if matrix[row][col - 1] == 1 and toggle == 1 or (matrix[row][col - 1] == 0 and toggle == 0) else 1
	if is_valid_index(col + 1):
		matrix[row][col + 1] = 0 if matrix[row][col + 1] == 1 and toggle == 1 or (matrix[row][col + 1] == 0 and toggle == 0) else 1
for row in range(3):
	current_row = [int(x) for x in input().split()]
	for col in range(3):
		toggle = current_row[col] % 2
		toggle_lights(row, col, toggle)
for row in range(3):
	x = matrix[row]
	print(''.join((str(elem) for elem in x)))


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)
	for row in lights:
		print(''.join([str(x) for x in row]))
main()


def light(lst):
	result = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
	for i in range(3):
		for j in range(3):
			s = 0
			if i - 1 >= 0 and j >= 0:
				s += lst[i - 1][j]
			if i >= 0 and j - 1 >= 0:
				s += lst[i][j - 1]
			if i + 1 <= 2 and j >= 0:
				s += lst[i + 1][j]
			if i >= 0 and j + 1 <= 2:
				s += lst[i][j + 1]
			s += lst[i][j]
			if s % 2 == 0:
				result[i][j] = 1
			if s % 2 != 0:
				result[i][j] = 0
	return result
b = list()
for i in range(3):
	a = [int(x) for x in input().split()]
	b.append(list(a))
for elem in light(b):
	print(''.join((str(e) for e in elem)))


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)
		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)
for i in range(0, 9):
	if i % 3 == 0 and i > 1:
		print('')
	print(final[i], end='')


z = [[0] * 5] * 2
for _ in range(1, 4):
	z.insert(_, [0] + list(map(int, input().split())) + [0])
for i in range(1, 4):
	for j in range(1, 4):
		print(((z[i - 1][j] + z[i + 1][j] + z[i][j - 1] + z[i][j + 1] + z[i][j]) % 2 + 1) % 2, end='')
	print()


arr = []
for x in range(3):
	t = [int(x) for x in input().split()]
	arr.append(t)
lights = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
nx = [0, -1, 0, 1]
ny = [-1, 0, 1, 0]
arn = arr
for x in range(3):
	for y in range(3):
		s = arr[x][y]
		for z in range(4):
			if x + nx[z] >= 0 and x + nx[z] < 3 and (y + ny[z] >= 0) and (y + ny[z] < 3):
				s += arr[x + nx[z]][y + ny[z]]
		lights[x][y] = 1 if s % 2 == 0 else 0
for x in range(3):
	print(''.join([str(k) for k in lights[x]]))


first = input().split(' ')
second = input().split(' ')
third = input().split(' ')
inputlamps = []
inputlamps.append(first)
inputlamps.append(second)
inputlamps.append(third)
lamps = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	for j in range(3):
		if inputlamps[i][j] != '0':
			lamps[i][j] += int(inputlamps[i][j])
			if i > 0:
				lamps[i - 1][j] += int(inputlamps[i][j])
			if j > 0:
				lamps[i][j - 1] += int(inputlamps[i][j])
			if i < 2:
				lamps[i + 1][j] += int(inputlamps[i][j])
			if j < 2:
				lamps[i][j + 1] += int(inputlamps[i][j])
for i in range(3):
	temp = ''
	for j in range(3):
		lamps[i][j] = lamps[i][j] % 2
		temp += str(lamps[i][j])
	print(temp)


def main():
	m = []
	for i in range(3):
		m.append([int(i) for i in input().split(' ')])
	ans = [[0] * 3 for i in range(3)]
	sum_ = 0
	for i in range(3):
		for j in range(3):
			sum_ += m[i][j]
			sum_ += m[i - 1][j] if i != 0 else 0
			sum_ += m[i + 1][j] if i != 2 else 0
			sum_ += m[i][j - 1] if j != 0 else 0
			sum_ += m[i][j + 1] if j != 2 else 0
			print(1 - sum_ % 2, end='')
			sum_ = 0
		print()
main()


inpt = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
outpt = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]

def input_binary_list():
	global inpt
	for i in range(3):
		string = input()
		for j in range(2):
			num = int(string[:string.find(' ')])
			string = string[string.find(' ') + 1:]
			if num % 2 != 0:
				inpt[i][j] = 1
		num = int(string)
		if num % 2 != 0:
			inpt[i][2] = 1

def switch():
	global outpt
	for i in range(3):
		for j in range(3):
			num = inpt[i][j]
			if num == 1:
				outpt[i][j] = 1 ^ outpt[i][j]
				if i - 1 != -1:
					outpt[i - 1][j] = 1 ^ outpt[i - 1][j]
				if i + 1 != 3:
					outpt[i + 1][j] = 1 ^ outpt[i + 1][j]
				if j - 1 != -1:
					outpt[i][j - 1] = 1 ^ outpt[i][j - 1]
				if j + 1 != 3:
					outpt[i][j + 1] = 1 ^ outpt[i][j + 1]

def output():
	for i in range(3):
		answer = ''
		for j in range(3):
			answer += str(outpt[i][j])
		print(answer)
input_binary_list()
switch()
output()


class Code:

	def __init__(self):
		self.row = []
		self.matrix = [[1] * 3 for _ in range(3)]
		for _ in range(3):
			self.row.append(list(map(int, input().split())))

	def process(self):
		for i in range(3):
			for j in range(3):
				if self.row[i][j] % 2 == 1:
					self.matrix[i][j] = (self.matrix[i][j] + 1) % 2
					if j < 2:
						self.matrix[i][j + 1] = (self.matrix[i][j + 1] + 1) % 2
					if j > 0:
						self.matrix[i][j - 1] = (self.matrix[i][j - 1] + 1) % 2
					if i < 2:
						self.matrix[i + 1][j] = (self.matrix[i + 1][j] + 1) % 2
					if i > 0:
						self.matrix[i - 1][j] = (self.matrix[i - 1][j] + 1) % 2
		for row in self.matrix:
			print(*row, sep='')
code = Code()
code.process()


def light_out(a):
	if a == 1:
		a = 0
		return a
	else:
		a = 1
		return a
static = [1, 1, 1, 1, 1, 1, 1, 1, 1]
stat = [0, 3, 6]
mass = []
for i in range(3):
	(a, b, c) = input().split()
	mass.append(int(a))
	mass.append(int(b))
	mass.append(int(c))
for i in range(len(mass)):
	for j in range(mass[i]):
		static[i] = light_out(static[i])
		if i // 3 == 0:
			static[i + 3] = light_out(static[i + 3])
		elif i // 3 == 2:
			static[i - 3] = light_out(static[i - 3])
		else:
			static[i + 3] = light_out(static[i + 3])
			static[i - 3] = light_out(static[i - 3])
		if i % 3 == 0:
			static[i + 1] = light_out(static[i + 1])
		elif i % 3 == 2:
			static[i - 1] = light_out(static[i - 1])
		else:
			static[i + 1] = light_out(static[i + 1])
			static[i - 1] = light_out(static[i - 1])
for i in stat:
	for j in range(2):
		print(static[i + j], end='')
	print(static[i + 2])


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


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

def troca0(A, xi, xj):
	imin = max(xi - 1, 0)
	jmin = max(xj - 1, 0)
	imax = min(xi + 1, 2)
	jmax = min(xj + 1, 2)
	i = imin
	while i <= imax:
		j = jmin
		while j <= jmax:
			A[i][j] = 1 - A[i][j]
			j += 1
		i += 1

def troca(A, i, j):
	u = 2
	l = 0
	if i - 1 >= l:
		A[i - 1][j] = 1 - A[i - 1][j]
	if i + 1 <= u:
		A[i + 1][j] = 1 - A[i + 1][j]
	if j - 1 >= l:
		A[i][j - 1] = 1 - A[i][j - 1]
	if j + 1 <= u:
		A[i][j + 1] = 1 - A[i][j + 1]
	A[i][j] = 1 - A[i][j]
A = []
A.append(list(map(int, input().split(' '))))
A.append(list(map(int, input().split(' '))))
A.append(list(map(int, input().split(' '))))
B = []
for i in range(3):
	B.append([1, 1, 1])
for i in range(3):
	for j in range(3):
		if A[i][j] % 2 != 0:
			troca(B, i, j)
imprime(B)


switched_times = []
switched_times.append(list(map(int, input().split())))
switched_times.append(list(map(int, input().split())))
switched_times.append(list(map(int, input().split())))
lights_state = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for row in range(0, 3):
	for column in range(0, 3):
		for (row_to_sum, column_to_sum) in [(row, column), (row - 1, column), (row + 1, column), (row, column - 1), (row, column + 1)]:
			if -1 < row_to_sum < 3 and -1 < column_to_sum < 3:
				lights_state[row][column] += switched_times[row_to_sum][column_to_sum]
		lights_state[row][column] = repr(lights_state[row][column] % 2)
for row in range(0, 3):
	print(''.join(lights_state[row]))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def intArr():
	return map(int, input().split())

def In():
	return int(input())

def func():
	pass

def main():
	arr = [list(intArr()) for _ in range(3)]
	l1 = [[1] * 3 for _ in range(3)]
	for i in range(3):
		for j in range(3):
			x = arr[i][j]
			l1[i][j] += x
			if i > 0:
				l1[i - 1][j] += x
			if i < 2:
				l1[i + 1][j] += x
			if j > 0:
				l1[i][j - 1] += x
			if j < 2:
				l1[i][j + 1] += x
	for i in range(3):
		for j in range(3):
			l1[i][j] %= 2
	print('\n'.join([''.join(map(str, l1[i])) for i in range(3)]))
	return
main()


matrix_input = [list(map(int, input().split())) for i in range(3)]
x = 1
matrix_output = [[x for i in range(3)] for j in range(3)]
y = 0
matrix_sum = [[y for i in range(3)] for j in range(3)]
matrix_sum[0][0] = matrix_input[0][0] + matrix_input[0][1] + matrix_input[1][0]
matrix_sum[0][1] = matrix_input[0][1] + matrix_input[0][0] + matrix_input[0][2] + matrix_input[1][1]
matrix_sum[0][2] = matrix_input[0][2] + matrix_input[0][1] + matrix_input[1][2]
matrix_sum[1][0] = matrix_input[1][0] + matrix_input[0][0] + matrix_input[1][1] + matrix_input[2][0]
matrix_sum[1][1] = matrix_input[1][1] + matrix_input[0][1] + matrix_input[2][1] + matrix_input[1][0] + matrix_input[1][2]
matrix_sum[1][2] = matrix_input[1][2] + matrix_input[0][2] + matrix_input[2][2] + matrix_input[1][1]
matrix_sum[2][0] = matrix_input[2][0] + matrix_input[1][0] + matrix_input[2][1]
matrix_sum[2][1] = matrix_input[2][1] + matrix_input[1][1] + matrix_input[2][0] + matrix_input[2][2]
matrix_sum[2][2] = matrix_input[2][2] + matrix_input[1][2] + matrix_input[2][1]
for row in range(3):
	for col in range(3):
		if matrix_sum[row][col] % 2 == 0:
			matrix_output[row][col] = 1
		else:
			matrix_output[row][col] = 0
for row in matrix_output:
	print(''.join(map(str, row)))


(g, fg) = ([], [[1, 1, 1], [1, 1, 1], [1, 1, 1]])
for i in range(3):
	g.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		g[i][j] %= 2
for i in range(3):
	for j in range(3):
		if g[i][j] == 1:
			fg[i][j] = 1 - fg[i][j]
			for a in [-1, 1]:
				if i + a >= 0 and i + a <= 2:
					fg[i + a][j] = 1 - fg[i + a][j]
			for b in [-1, 1]:
				if j + b >= 0 and j + b <= 2:
					fg[i][j + b] = 1 - fg[i][j + b]
for i in range(3):
	print(fg[i][0], fg[i][1], fg[i][2], sep='')


matrix = []
for _ in range(3):
	linha = list(input().split())
	linha = [int(i) for i in linha]
	matrix.append(linha)
matrix_ini = []
for _ in range(3):
	matrix_ini.append([1, 1, 1])
for i in range(3):
	for j in range(3):
		n = matrix[i][j]
		if n % 2 == 0:
			continue
		matrix_ini[i][j] = (matrix_ini[i][j] + 1) % 2
		if i == 0:
			matrix_ini[i + 1][j] = (matrix_ini[i + 1][j] + 1) % 2
		if i == 1:
			matrix_ini[i - 1][j] = (matrix_ini[i - 1][j] + 1) % 2
			matrix_ini[i + 1][j] = (matrix_ini[i + 1][j] + 1) % 2
		if i == 2:
			matrix_ini[i - 1][j] = (matrix_ini[i - 1][j] + 1) % 2
		if j == 0:
			matrix_ini[i][j + 1] = (matrix_ini[i][j + 1] + 1) % 2
		if j == 1:
			matrix_ini[i][j + 1] = (matrix_ini[i][j + 1] + 1) % 2
			matrix_ini[i][j - 1] = (matrix_ini[i][j - 1] + 1) % 2
		if j == 2:
			matrix_ini[i][j - 1] = (matrix_ini[i][j - 1] + 1) % 2
output = ''
for i in matrix_ini:
	output += '{}{}{}\n'.format(i[0], i[1], i[2])
print(output)


(a, b, c) = map(int, input().split())
(x, y, z) = map(int, input().split())
(i, j, k) = map(int, input().split())
a1 = x + b + a
b1 = a + b + c + y
c1 = b + z + c
x1 = a + x + y + i
y1 = b + y + j + x + z
z1 = y + z + k + c
i1 = x + j + i
j1 = i + y + j + k
k1 = j + z + k
arr = [a1, b1, c1, x1, y1, z1, i1, j1, k1]
brr = []
for i in range(len(arr)):
	if arr[i] % 2 == 0:
		brr.append('1')
	else:
		brr.append('0')
print(brr[0] + brr[1] + brr[2])
print(brr[3] + brr[4] + brr[5])
print(brr[6] + brr[7] + brr[8])


grid = [[1 for i in range(3)] for j in range(3)]
toggle = []
coords = [[0, 1], [1, 0], [-1, 0], [0, -1]]
for j in range(3):
	a = input().split()
	toggle.append(list(map(int, a)))
for i in range(3):
	for j in range(3):
		total = toggle[i][j]
		for (dx, dy) in coords:
			(nx, ny) = (dx + j, dy + i)
			if 3 > nx >= 0 and 3 > ny >= 0:
				total += toggle[ny][nx]
		grid[i][j] = 1 - total % 2
for m in grid:
	print(''.join(list(map(str, m))))


n = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
r = [] * 3
for i in range(3):
	r.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		if r[i][j] > 0 and r[i][j] % 2 != 0:
			n[i][j] = 0 if n[i][j] == 1 else 1
			if j != 2 and j != 0:
				n[i][j + 1] = 0 if n[i][j + 1] == 1 else 1
				n[i][j - 1] = 0 if n[i][j - 1] == 1 else 1
			if i != 2 and i != 0:
				n[i + 1][j] = 0 if n[i + 1][j] == 1 else 1
				n[i - 1][j] = 0 if n[i - 1][j] == 1 else 1
			if j != 2 and j == 0:
				n[i][j + 1] = 0 if n[i][j + 1] == 1 else 1
			if j == 2 and j != 0:
				n[i][j - 1] = 0 if n[i][j - 1] == 1 else 1
			if i != 2 and i == 0:
				n[i + 1][j] = 0 if n[i + 1][j] == 1 else 1
			if i == 2 and i != 0:
				n[i - 1][j] = 0 if n[i - 1][j] == 1 else 1
for i in range(3):
	for j in range(3):
		print(n[i][j], end='')
	print()


movx = [0, 0, -1, 1]
movy = [1, -1, 0, 0]

def valid(x, y):
	if 0 <= x < 3 and 0 <= y < 3:
		return True
	return False
mat = []
for i in range(3):
	mat.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		sm = mat[i][j]
		for k in range(4):
			if valid(i + movx[k], j + movy[k]):
				sm += mat[i + movx[k]][j + movy[k]]
		print(1 - sm % 2, end='')
	print()


inp = []
matrix = [[1] * 3 for i in range(3)]

def press_button(i, j, n):
	if n % 2:
		matrix[i][j] = 0 if matrix[i][j] == 1 else 1
		if i - 1 >= 0:
			matrix[i - 1][j] = 0 if matrix[i - 1][j] == 1 else 1
		if i + 1 < 3:
			matrix[i + 1][j] = 0 if matrix[i + 1][j] == 1 else 1
		if j + 1 < 3:
			matrix[i][j + 1] = 0 if matrix[i][j + 1] == 1 else 1
		if j - 1 >= 0:
			matrix[i][j - 1] = 0 if matrix[i][j - 1] == 1 else 1
for i in range(3):
	inp.append(list(map(int, input().strip().split())))
for i in range(3):
	for j in range(3):
		press_button(i, j, inp[i][j])
matrix = [list(map(str, x)) for x in matrix]
matrix = [''.join(a) for a in matrix]
print('\n'.join(matrix))


(x11, x12, x13) = map(int, input().split())
(x21, x22, x23) = map(int, input().split())
(x31, x32, x33) = map(int, input().split())
print('1' if (x11 + x12 + x21) % 2 == 0 else '0', '1' if (x11 + x12 + x13 + x22) % 2 == 0 else '0', '1' if (x12 + x13 + x23) % 2 == 0 else '0', sep='')
print('1' if (x11 + x21 + x22 + x31) % 2 == 0 else '0', '1' if (x12 + x21 + x22 + x23 + x32) % 2 == 0 else '0', '1' if (x13 + x22 + x23 + x33) % 2 == 0 else '0', sep='')
print('1' if (x21 + x31 + x32) % 2 == 0 else '0', '1' if (x22 + x31 + x32 + x33) % 2 == 0 else '0', '1' if (x23 + x32 + x33) % 2 == 0 else '0', sep='')


r1 = input().split()
r1 = [int(i) for i in r1]
r2 = input().split()
r2 = [int(i) for i in r2]
r3 = input().split()
r3 = [int(i) for i in r3]
light = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
data = []
data.append(r1)
data.append(r2)
data.append(r3)
for i in range(3):
	for j in range(3):
		for k in range(data[i][j]):
			if i == 0:
				if j == 0:
					light[i][0] = 1 - light[i][0]
					light[i][1] = 1 - light[i][1]
					light[i + 1][0] = 1 - light[i + 1][0]
				elif j == 1:
					light[i][0] = 1 - light[i][0]
					light[i][1] = 1 - light[i][1]
					light[i][2] = 1 - light[i][2]
					light[i + 1][1] = 1 - light[i + 1][1]
				else:
					light[i][1] = 1 - light[i][1]
					light[i][2] = 1 - light[i][2]
					light[i + 1][2] = 1 - light[i + 1][2]
			if i == 1:
				if j == 0:
					light[i][0] = 1 - light[i][0]
					light[i][1] = 1 - light[i][1]
					light[i - 1][0] = 1 - light[i - 1][0]
					light[i + 1][0] = 1 - light[i + 1][0]
				elif j == 1:
					light[i][0] = 1 - light[i][0]
					light[i][1] = 1 - light[i][1]
					light[i][2] = 1 - light[i][2]
					light[i + 1][1] = 1 - light[i + 1][1]
					light[i - 1][1] = 1 - light[i - 1][1]
				else:
					light[i][1] = 1 - light[i][1]
					light[i][2] = 1 - light[i][2]
					light[i + 1][2] = 1 - light[i + 1][2]
					light[i - 1][2] = 1 - light[i - 1][2]
			if i == 2:
				if j == 0:
					light[i][0] = 1 - light[i][0]
					light[i][1] = 1 - light[i][1]
					light[i - 1][0] = 1 - light[i - 1][0]
				elif j == 1:
					light[i][0] = 1 - light[i][0]
					light[i][1] = 1 - light[i][1]
					light[i][2] = 1 - light[i][2]
					light[i - 1][1] = 1 - light[i - 1][1]
				else:
					light[i][1] = 1 - light[i][1]
					light[i][2] = 1 - light[i][2]
					light[i - 1][2] = 1 - light[i - 1][2]
print(light[0][0], light[0][1], light[0][2], sep='')
print(light[1][0], light[1][1], light[1][2], sep='')
print(light[2][0], light[2][1], light[2][2], sep='')


lights = [[True, True, True], [True, True, True], [True, True, True]]
clicks = []
for i in range(3):
	clicks.append(list(map(int, input().strip().split())))

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

def switch_lights(r, c):
	lights[r][c] = not lights[r][c]
	i = max(0, r - 1)
	if i != r:
		lights[i][c] = not lights[i][c]
	i = min(2, r + 1)
	if i != r:
		lights[i][c] = not lights[i][c]
	j = max(0, c - 1)
	if j != c:
		lights[r][j] = not lights[r][j]
	j = min(2, c + 1)
	if j != c:
		lights[r][j] = not lights[r][j]
for i in range(3):
	for j in range(3):
		if clicks[i][j] % 2 == 1:
			switch_lights(i, j)
print_board()


l = []
for i in range(3):
	s = str(input())
	l.append(s.split(' '))
a = [[1 for i in range(3)] for j in range(3)]
for i in range(int(l[0][0])):
	a[0][0] = 1 - a[0][0]
	a[0][1] = 1 - a[0][1]
	a[1][0] = 1 - a[1][0]
for i in range(int(l[0][1])):
	a[0][1] = 1 - a[0][1]
	a[0][0] = 1 - a[0][0]
	a[0][2] = 1 - a[0][2]
	a[1][1] = 1 - a[1][1]
for i in range(int(l[0][2])):
	a[0][2] = 1 - a[0][2]
	a[0][1] = 1 - a[0][1]
	a[1][2] = 1 - a[1][2]
for i in range(int(l[1][0])):
	a[1][0] = 1 - a[1][0]
	a[0][0] = 1 - a[0][0]
	a[1][1] = 1 - a[1][1]
	a[2][0] = 1 - a[2][0]
for i in range(int(l[1][1])):
	a[1][1] = 1 - a[1][1]
	a[1][0] = 1 - a[1][0]
	a[0][1] = 1 - a[0][1]
	a[1][2] = 1 - a[1][2]
	a[2][1] = 1 - a[2][1]
for i in range(int(l[1][2])):
	a[1][2] = 1 - a[1][2]
	a[0][2] = 1 - a[0][2]
	a[1][1] = 1 - a[1][1]
	a[2][2] = 1 - a[2][2]
for i in range(int(l[2][0])):
	a[2][0] = 1 - a[2][0]
	a[1][0] = 1 - a[1][0]
	a[2][1] = 1 - a[2][1]
for i in range(int(l[2][1])):
	a[2][1] = 1 - a[2][1]
	a[2][0] = 1 - a[2][0]
	a[1][1] = 1 - a[1][1]
	a[2][2] = 1 - a[2][2]
for i in range(int(l[2][2])):
	a[2][2] = 1 - a[2][2]
	a[2][1] = 1 - a[2][1]
	a[1][2] = 1 - a[1][2]
for i in range(3):
	s = ''
	for j in range(3):
		s += str(a[i][j])
	print(s)


fl = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
l1 = []
for i in range(3):
	l2 = []
	l2 = list(map(int, input().split(' ')))
	l1.append(l2)
for i in range(len(l1)):
	for j in range(len(l1[i])):
		if l1[i][j] % 2 != 0:
			if fl[i][j] == 0:
				fl[i][j] += 1
			else:
				fl[i][j] = 0
			if i - 1 >= 0:
				if fl[i - 1][j] == 0:
					fl[i - 1][j] += 1
				else:
					fl[i - 1][j] = 0
			if j - 1 >= 0:
				if fl[i][j - 1] == 0:
					fl[i][j - 1] += 1
				else:
					fl[i][j - 1] = 0
			if i + 1 <= 2:
				if fl[i + 1][j] == 0:
					fl[i + 1][j] += 1
				else:
					fl[i + 1][j] = 0
			if j + 1 <= 2:
				if fl[i][j + 1] == 0:
					fl[i][j + 1] += 1
				else:
					fl[i][j + 1] = 0
for i in fl:
	for j in i:
		print(j, end='')
	print('\n', end='')


a = [0 for i in range(9)]
(a[0], a[1], a[2]) = map(int, input().split())
(a[3], a[4], a[5]) = map(int, input().split())
(a[6], a[7], a[8]) = map(int, input().split())
print(1 - (a[0] + a[1] + a[3]) % 2, end='')
print(1 - (a[1] + a[0] + a[2] + a[4]) % 2, end='')
print(1 - (a[1] + a[2] + a[5]) % 2)
print(1 - (a[0] + a[3] + a[4] + a[6]) % 2, end='')
print(1 - (a[1] + a[4] + a[3] + a[5] + a[7]) % 2, end='')
print(1 - (a[4] + a[2] + a[5] + a[8]) % 2)
print(1 - (a[3] + a[6] + a[7]) % 2, end='')
print(1 - (a[4] + a[7] + a[6] + a[8]) % 2, end='')
print(1 - (a[5] + a[7] + a[8]) % 2, end='')


l = [[int(j) for j in input().split()] for i in range(3)]
p = [[0 for i in range(3)] for j in range(3)]
p[0][0] = l[0][0] + l[1][0] + l[0][1]
p[0][1] = l[0][0] + l[1][1] + l[0][1] + l[0][2]
p[0][2] = l[0][1] + l[1][2] + l[0][2]
p[1][0] = l[0][0] + l[1][0] + l[2][0] + l[1][1]
p[1][1] = l[1][1] + l[1][0] + l[0][1] + l[1][2] + l[2][1]
p[1][2] = l[0][2] + l[1][1] + l[1][2] + l[2][2]
p[2][0] = l[2][0] + l[1][0] + l[2][1]
p[2][1] = l[2][0] + l[2][1] + l[2][2] + l[1][1]
p[2][2] = l[2][2] + l[2][1] + l[1][2]
for i in range(3):
	for j in range(3):
		if p[i][j] % 2 != 0:
			p[i][j] = 0
			print(p[i][j], end='')
		else:
			p[i][j] = 1
			print(p[i][j], end='')
	print()


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

def swap(arg1):
	if arg1 == 0 or arg1 == '0':
		arg1 = '1'
	elif arg1 == 1 or arg1 == '1':
		arg1 = '0'
	return arg1
lights = [['1', '1', '1'], ['1', '1', '1'], ['1', '1', '1']]
for j in range(3):
	for k in range(3):
		if room[j][k] % 2 == 1:
			room[j][k] = 1
		else:
			room[j][k] = 0
for J in range(3):
	for K in range(3):
		if room[J][K] == 1:
			lights[J][K] = swap(lights[J][K])
			if K > 0:
				lights[J][K - 1] = swap(lights[J][K - 1])
			if K < 2:
				lights[J][K + 1] = swap(lights[J][K + 1])
			if J > 0:
				lights[J - 1][K] = swap(lights[J - 1][K])
			if J < 2:
				lights[J + 1][K] = swap(lights[J + 1][K])
		else:
			continue
(Lights0, Lights1, Lights2) = (str(), str(), str())
for L in range(3):
	Lights0 += lights[0][L]
	Lights1 += lights[1][L]
	Lights2 += lights[2][L]
print(Lights0)
print(Lights1)
print(Lights2)


grid = [[1 for i in range(3)] for j in range(3)]
for i in range(3):
	n = list(map(int, input().split()))
	for j in range(3):
		if n[j] % 2:
			grid[i][j] = abs(grid[i][j] - 1)
			if 0 < i:
				grid[i - 1][j] = abs(grid[i - 1][j] - 1)
			if i + 1 < 3:
				grid[i + 1][j] = abs(grid[i + 1][j] - 1)
			if 0 < j:
				grid[i][j - 1] = abs(grid[i][j - 1] - 1)
			if j + 1 < 3:
				grid[i][j + 1] = abs(grid[i][j + 1] - 1)
for i in range(3):
	for j in range(3):
		print(grid[i][j], end='')
	print()


def neighbours(i, j):
	global grid
	if i == 0:
		if j == 0:
			return grid[i][j + 1] + grid[i + 1][j]
		elif j == 2:
			return grid[i][j - 1] + grid[i + 1][j]
		else:
			return grid[i][j + 1] + grid[i][j - 1] + grid[i + 1][j]
	elif i == 1:
		if j == 0:
			return grid[i][j + 1] + grid[i + 1][j] + grid[i - 1][j]
		elif j == 2:
			return grid[i][j - 1] + grid[i + 1][j] + grid[i - 1][j]
		else:
			return grid[i][j + 1] + grid[i][j - 1] + grid[i + 1][j] + grid[i - 1][j]
	elif i == 2:
		if j == 0:
			return grid[i][j + 1] + grid[i - 1][j]
		elif j == 2:
			return grid[i][j - 1] + grid[i - 1][j]
		else:
			return grid[i][j + 1] + grid[i][j - 1] + grid[i - 1][j]
grid = []
new_grid = [[0 for x in range(3)] for x in range(3)]
for _ in range(3):
	grid.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		new_grid[i][j] = grid[i][j] + neighbours(i, j)
		if new_grid[i][j] % 2 == 0:
			print(1, end='')
		else:
			print(0, end='')
	print('')


(N, M) = (3, 3)
grid = [[True for _ in range(M)] for _ in range(N)]
for i in range(N):
	for (j, n) in enumerate(map(int, input().split())):
		if not n & 1:
			continue
		grid[i][j] = not grid[i][j]
		if i:
			grid[i - 1][j] = not grid[i - 1][j]
		if j:
			grid[i][j - 1] = not grid[i][j - 1]
		if i + 1 < N:
			grid[i + 1][j] = not grid[i + 1][j]
		if j + 1 < M:
			grid[i][j + 1] = not grid[i][j + 1]
for i in range(N):
	print(*[int(grid[i][j]) for j in range(M)], sep='')


def is_good(y, x):
	return 0 <= y < 3 and 0 <= x < 3
l = [[int(i) for i in input().split()] for _ in range(3)]
table = [[1 for i in range(3)] for _ in range(3)]
for i in range(3):
	for j in range(3):
		for k in range(l[i][j]):
			table[i][j] = (table[i][j] + 1) % 2
			for (y, x) in ((i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1)):
				if is_good(y, x):
					table[y][x] = (table[y][x] + 1) % 2
for i in range(3):
	print(''.join(map(str, table[i])))


lights = [[1 for _ in range(5)] for _ in range(5)]
for i in range(1, 4):
	row = list(map(int, input().split()))
	for j in range(1, 4):
		lights[i][j] += row[j - 1]
		lights[i - 1][j] += row[j - 1]
		lights[i + 1][j] += row[j - 1]
		lights[i][j - 1] += row[j - 1]
		lights[i][j + 1] += row[j - 1]
for i in range(1, 4):
	print(''.join(list(map(lambda x: str(x % 2), lights[i][1:4]))))


a = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
b = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

def switch(arr, i, j):
	if i == 1:
		if j == 1:
			arr = swtop(arr, i, j)
			arr = swbot(arr, i, j)
			arr = swleft(arr, i, j)
			arr = swright(arr, i, j)
		elif j < 1:
			arr = swtop(arr, i, j)
			arr = swbot(arr, i, j)
			arr = swright(arr, i, j)
		else:
			arr = swtop(arr, i, j)
			arr = swbot(arr, i, j)
			arr = swleft(arr, i, j)
	elif i < 1:
		if j == 1:
			arr = swbot(arr, i, j)
			arr = swleft(arr, i, j)
			arr = swright(arr, i, j)
		elif j < 1:
			arr = swbot(arr, i, j)
			arr = swright(arr, i, j)
		else:
			arr = swbot(arr, i, j)
			arr = swleft(arr, i, j)
	elif j == 1:
		arr = swtop(arr, i, j)
		arr = swleft(arr, i, j)
		arr = swright(arr, i, j)
	elif j < 1:
		arr = swtop(arr, i, j)
		arr = swright(arr, i, j)
	else:
		arr = swtop(arr, i, j)
		arr = swleft(arr, i, j)
	return arr

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

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

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

def swright(arr, i, j):
	if arr[i][j + 1] == 1:
		arr[i][j + 1] = 0
	else:
		arr[i][j + 1] = 1
	return arr
for i in range(3):
	c = input('').split()
	for j in range(3):
		if int(c[j]) % 2 == 0:
			c[j] = 0
		else:
			c[j] = 1
	b[i] = c
for i in range(len(b)):
	for j in range(len(b[i])):
		if b[i][j] == 1:
			if a[i][j] == 1:
				a[i][j] = 0
			else:
				a[i][j] = 1
			a = switch(a, i, j)
ar = ['', '', '']
for i in range(len(a)):
	st = ''
	for e in a[i]:
		st += str(e)
	ar[i] = st
for d in ar:
	print(d)


x = [[0, 0, 0, 0, 0]]

def con(m):
	if m == 0:
		return 1
	else:
		return 0
for i in range(3):
	x.append([0] + list(map(int, input().split())) + [0])
x.append([0, 0, 0, 0, 0])
y = []
for i in range(5):
	a = []
	for j in range(5):
		a.append(1)
	y.append(a)
for i in range(1, 4):
	for j in range(1, 4):
		if x[i][j] % 2 != 0:
			y[i][j] = con(y[i][j])
			y[i][j - 1] = con(y[i][j - 1])
			y[i][j + 1] = con(y[i][j + 1])
			y[i - 1][j] = con(y[i - 1][j])
			y[i + 1][j] = con(y[i + 1][j])
for i in range(1, 4):
	for j in range(1, 4):
		print(y[i][j], 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)
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()


a = input()
b = input()
c = input()
a = a.split()
a = list(map(int, a))
b = b.split()
b = list(map(int, b))
c = c.split()
c = list(map(int, c))
a = [i % 2 for i in a]
b = [i % 2 for i in b]
c = [i % 2 for i in c]
d = [1, 1, 1, 1, 1, 1, 1, 1, 1]
if a[0] == 1:
	d[0] += 1
	d[1] += 1
	d[3] += 1
if a[1] == 1:
	d[0] += 1
	d[1] += 1
	d[2] += 1
	d[4] += 1
if a[2] == 1:
	d[1] += 1
	d[2] += 1
	d[5] += 1
if b[0] == 1:
	d[0] += 1
	d[3] += 1
	d[4] += 1
	d[6] += 1
if b[1] == 1:
	d[1] += 1
	d[3] += 1
	d[4] += 1
	d[5] += 1
	d[7] += 1
if b[2] == 1:
	d[2] += 1
	d[4] += 1
	d[5] += 1
	d[8] += 1
if c[0] == 1:
	d[3] += 1
	d[6] += 1
	d[7] += 1
if c[1] == 1:
	d[4] += 1
	d[6] += 1
	d[7] += 1
	d[8] += 1
if c[2] == 1:
	d[5] += 1
	d[7] += 1
	d[8] += 1
d = [i % 2 for i in d]
d = list(map(str, d))
print(d[0] + d[1] + d[2])
print(d[3] + d[4] + d[5])
print(d[6] + d[7] + d[8])


s = []
l = [1, 1, 1, 1, 1, 1, 1, 1, 1]
for i in range(3):
	s += list(map(int, input().split()))
for i in range(9):
	if s[i] % 2 != 0:
		if i == 0:
			for j in [0, 1, 3]:
				if l[j] == 1:
					l[j] = 0
				else:
					l[j] = 1
		elif i == 1:
			for j in [0, 1, 2, 4]:
				if l[j] == 1:
					l[j] = 0
				else:
					l[j] = 1
		elif i == 2:
			for j in [1, 2, 5]:
				if l[j] == 1:
					l[j] = 0
				else:
					l[j] = 1
		elif i == 3:
			for j in [0, 3, 4, 6]:
				if l[j] == 1:
					l[j] = 0
				else:
					l[j] = 1
		elif i == 4:
			for j in [1, 3, 5, 7, 4]:
				if l[j] == 1:
					l[j] = 0
				else:
					l[j] = 1
		elif i == 5:
			for j in [2, 4, 5, 8]:
				if l[j] == 1:
					l[j] = 0
				else:
					l[j] = 1
		elif i == 6:
			for j in [3, 6, 7]:
				if l[j] == 1:
					l[j] = 0
				else:
					l[j] = 1
		elif i == 7:
			for j in [4, 6, 7, 8]:
				if l[j] == 1:
					l[j] = 0
				else:
					l[j] = 1
		elif i == 8:
			for j in [5, 7, 8]:
				if l[j] == 1:
					l[j] = 0
				else:
					l[j] = 1
for i in l[0:3]:
	print(i, end='')
print()
for i in l[3:6]:
	print(i, end='')
print()
for i in l[6:9]:
	print(i, end='')


import copy
lst = []
lst1 = []
for i in range(3):
	(a, b, c) = [int(x) for x in input().split()]
	lst.append(a)
	lst.append(b)
	lst.append(c)
for i in range(9):
	lst[i] = lst[i] % 2
lst1 = lst.copy()
if lst[0] == 1:
	lst1[1] += 1
	lst1[3] += 1
if lst[1] == 1:
	lst1[0] += 1
	lst1[2] += 1
	lst1[4] += 1
if lst[2] == 1:
	lst1[1] += 1
	lst1[5] += 1
if lst[3] == 1:
	lst1[0] += 1
	lst1[4] += 1
	lst1[6] += 1
if lst[4] == 1:
	lst1[1] += 1
	lst1[3] += 1
	lst1[5] += 1
	lst1[7] += 1
if lst[5] == 1:
	lst1[2] += 1
	lst1[4] += 1
	lst1[8] += 1
if lst[6] == 1:
	lst1[3] += 1
	lst1[7] += 1
if lst[7] == 1:
	lst1[4] += 1
	lst1[6] += 1
	lst1[8] += 1
if lst[8] == 1:
	lst1[5] += 1
	lst1[7] += 1
for i in range(9):
	lst1[i] = lst1[i] % 2
for i in range(9):
	if lst1[i] == 1:
		lst1[i] = 0
	else:
		lst1[i] = 1
st = ''.join((str(x) for x in lst1))
print('{} \n{} \n{}'.format(st[0:3], st[3:6], st[6:9]))


def toggle(g, i, j):
	g[i][j] = ~g[i][j] + 2
	if i < 2:
		g[i + 1][j] = ~g[i + 1][j] + 2
	if i > 0:
		g[i - 1][j] = ~g[i - 1][j] + 2
	if j < 2:
		g[i][j + 1] = ~g[i][j + 1] + 2
	if j > 0:
		g[i][j - 1] = ~g[i][j - 1] + 2
l_grid = [[1, 1, 1] for _ in range(3)]
l_prs = []
for _ in range(3):
	l_prs.append(tuple(map(int, input().split())))
for i in range(3):
	for j in range(3):
		if l_prs[i][j] & 1:
			toggle(l_grid, i, j)
for i in range(3):
	print(*l_grid[i], sep='')


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


a = []
b = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	row = list(map(int, input().split()))
	a.append(row)
for i in range(3):
	for j in range(3):
		if a[i][j] % 2 != 0 and a[i][j] != 0:
			b[i][j] ^= 1
			if j + 1 < 3:
				b[i][j + 1] ^= 1
			if j - 1 >= 0:
				b[i][j - 1] ^= 1
			if i - 1 >= 0:
				b[i - 1][j] ^= 1
			if i + 1 < 3:
				b[i + 1][j] ^= 1
for i in range(3):
	for j in range(3):
		print(b[i][j], end='')
	print(end='\n')


opera = []
for i in range(3):
	lst = list(map(int, input().split()))
	for j in range(3):
		if lst[j] % 2 == 0:
			lst[j] = 0
		else:
			lst[j] = 1
	opera.append(lst)
lights = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	for j in range(3):
		if opera[i][j] == 1:
			if lights[i][j] == 1:
				lights[i][j] = 0
			else:
				lights[i][j] = 1
			if j + 1 < 3:
				if lights[i][j + 1] == 1:
					lights[i][j + 1] = 0
				else:
					lights[i][j + 1] = 1
			if j - 1 >= 0:
				if lights[i][j - 1] == 1:
					lights[i][j - 1] = 0
				else:
					lights[i][j - 1] = 1
			if i - 1 >= 0:
				if lights[i - 1][j] == 1:
					lights[i - 1][j] = 0
				else:
					lights[i - 1][j] = 1
			if i + 1 < 3:
				if lights[i + 1][j] == 1:
					lights[i + 1][j] = 0
				else:
					lights[i + 1][j] = 1
for i in range(3):
	print(''.join(map(str, lights[i])))


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


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


def main():
	pressed = [[1] * 3 for _ in range(3)]
	grid = list()
	for _ in range(3):
		grid.append(list(map(int, input().strip().split())))
	for row in range(3):
		for col in range(3):
			if grid[row][col] != 0:
				countPressed(grid[row][col], row, col, pressed)
	for row in range(3):
		for col in range(3):
			pressed[row][col] %= 2
	for _ in range(3):
		print(*pressed[_], sep='')

def countPressed(toggled, row, col, pressed):
	pressed[row][col] += toggled
	if row + 1 < 3:
		pressed[row + 1][col] += toggled
	if row - 1 >= 0:
		pressed[row - 1][col] += toggled
	if col + 1 < 3:
		pressed[row][col + 1] += toggled
	if col - 1 >= 0:
		pressed[row][col - 1] += toggled
main()


list1 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
list2 = [list(map(int, input().strip().split()))[:3], list(map(int, input().strip().split()))[:3], list(map(int, input().strip().split()))[:3]]
for i in range(3):
	for j in range(3):
		if list2[i][j] % 2 != 0:
			list1[i][j] = not list1[i][j]
			if j + 1 <= 2:
				list1[i][j + 1] = not list1[i][j + 1]
			if i + 1 <= 2:
				list1[i + 1][j] = not list1[i + 1][j]
			if i - 1 >= 0:
				list1[i - 1][j] = not list1[i - 1][j]
			if j - 1 >= 0:
				list1[i][j - 1] = not list1[i][j - 1]
for i in range(3):
	for j in range(3):
		if list1[i][j] == False:
			list1[i][j] = 0
		elif list1[i][j] == True:
			list1[i][j] = 1
for i in range(3):
	print(''.join(map(str, list1[i])))


def count(a, i, j):
	total = 1
	for (x, y) in ((-1, 0), (0, -1), (0, 0), (0, 1), (1, 0)):
		if 0 <= i + x < 3 and 0 <= j + y < 3:
			total += a[i + x][j + y]
	return str(total % 2)
a = list((list(map(int, input().split())) for _ in range(3)))
for i in range(3):
	print(''.join([count(a, i, j) for j in range(3)]))


a = list()
for _ in range(3):
	(x, y, z) = map(int, input().split())
	a.append(x)
	a.append(y)
	a.append(z)
for i in range(9):
	if i % 3 == 0 and i != 0:
		print('')
	if i == 0:
		print('1' if (a[i] + a[i + 1] + a[i + 3]) % 2 == 0 else '0', end='')
	if i == 1:
		print('1' if (a[i] + a[i + 1] + a[i + 3] + a[i - 1]) % 2 == 0 else '0', end='')
	if i == 2:
		print('1' if (a[i] + a[i + 3] + a[i - 1]) % 2 == 0 else '0', end='')
	if i == 3:
		print('1' if (a[i] + a[i + 1] + a[i + 3] + a[i - 3]) % 2 == 0 else '0', end='')
	if i == 4:
		print('1' if (a[i] + a[i + 1] + a[i + 3] + a[i - 3] + a[i - 1]) % 2 == 0 else '0', end='')
	if i == 5:
		print('1' if (a[i] + a[i + 3] + a[i - 3] + a[i - 1]) % 2 == 0 else '0', end='')
	if i == 6:
		print('1' if (a[i] + a[i + 1] + a[i - 3]) % 2 == 0 else '0', end='')
	if i == 7:
		print('1' if (a[i] + a[i + 1] + a[i - 3] + a[i - 1]) % 2 == 0 else '0', end='')
	if i == 8:
		print('1' if (a[i] + a[i - 3] + a[i - 1]) % 2 == 0 else '0', end='')


l = [list(map(int, input().split())) for i in range(3)]
matrix = [[0 for _ in range(3)] for j in range(3)]
for i in range(3):
	ans = ''
	for j in range(3):
		cur = l[i][j]
		if i > 0:
			cur += l[i - 1][j]
		if i < 2:
			cur += l[i + 1][j]
		if j > 0:
			cur += l[i][j - 1]
		if j < 2:
			cur += l[i][j + 1]
		if not cur % 2:
			ans += '1'
		else:
			ans += '0'
	print(ans)


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


l = [list(map(int, input().split())) for y in range(3)]
state = [[True for i in range(3)] for _ in range(3)]
moves = [[-1, 0], [1, 0], [0, -1], [0, 1]]
for i in range(3):
	for j in range(3):
		l[i][j] %= 2
		if l[i][j] == 1:
			state[i][j] = not state[i][j]
			for n in moves:
				if i + n[0] >= 0 and i + n[0] < 3 and (j + n[1] >= 0) and (j + n[1] < 3):
					state[i + n[0]][j + n[1]] = not state[i + n[0]][j + n[1]]
for i in range(3):
	for j in range(3):
		if state[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] += 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()


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(input().split())
for linha in range(len(matriz)):
	for coluna in range(len(matriz[linha])):
		if int(matriz[linha][coluna]) % 2 != 0:
			inicial[linha][coluna] = switcher(inicial[linha][coluna])
			if coluna - 1 >= 0 and coluna - 1 < 3:
				inicial[linha][coluna - 1] = switcher(inicial[linha][coluna - 1])
			if coluna + 1 >= 0 and coluna + 1 < 3:
				inicial[linha][coluna + 1] = switcher(inicial[linha][coluna + 1])
			if linha - 1 >= 0 and linha - 1 < 3:
				inicial[linha - 1][coluna] = switcher(inicial[linha - 1][coluna])
			if linha + 1 >= 0 and linha + 1 < 3:
				inicial[linha + 1][coluna] = switcher(inicial[linha + 1][coluna])
print(''.join(inicial[0]))
print(''.join(inicial[1]))
print(''.join(inicial[2]))


from sys import stdin
import math
inp = lambda : stdin.readline().strip()
matrix = []
ans = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	matrix.append([int(x) for x in inp().split()])
for i in range(3):
	for j in range(3):
		if matrix[i][j] % 2 == 1:
			ans[i][j] = abs(ans[i][j] - 1)
			for k in range(-1, 2, 1):
				for l in range(-1, 2, 1):
					if 0 <= i + k < 3:
						ans[i + k][j] = abs(ans[i + k][j] - 1)
					if 0 <= j + l < 3:
						ans[i][j + l] = abs(ans[i][j + l] - 1)
for i in range(3):
	print(''.join(map(str, ans[i])))


t = []
k = [['1', '1', '1'], ['1', '1', '1'], ['1', '1', '1']]
for i in range(3):
	a = list(map(int, input().split()))
	if a[0] == 0:
		pass
	elif a[0] % 2 == 0:
		pass
	else:
		k[i][0] = str(abs(int(k[i][0]) - 1))
		k[i][1] = str(abs(int(k[i][1]) - 1))
		if i == 0:
			k[i + 1][0] = str(abs(int(k[i + 1][0]) - 1))
		elif i == 1:
			k[i + 1][0] = str(abs(int(k[i + 1][0]) - 1))
			k[i - 1][0] = str(abs(int(k[i - 1][0]) - 1))
		else:
			k[i - 1][0] = str(abs(int(k[i - 1][0]) - 1))
	if a[1] == 0:
		pass
	elif a[1] % 2 == 0:
		pass
	else:
		k[i][1] = str(abs(int(k[i][1]) - 1))
		k[i][0] = str(abs(int(k[i][0]) - 1))
		k[i][2] = str(abs(int(k[i][2]) - 1))
		if i == 0:
			k[i + 1][1] = str(abs(int(k[i + 1][1]) - 1))
		elif i == 1:
			k[i + 1][1] = str(abs(int(k[i + 1][1]) - 1))
			k[i - 1][1] = str(abs(int(k[i - 1][1]) - 1))
		else:
			k[i - 1][1] = str(abs(int(k[i - 1][1]) - 1))
	if a[2] == 0:
		pass
	elif a[2] % 2 == 0:
		pass
	else:
		k[i][2] = str(abs(int(k[i][2]) - 1))
		k[i][1] = str(abs(int(k[i][1]) - 1))
		if i == 0:
			k[i + 1][2] = str(abs(int(k[i + 1][2]) - 1))
		elif i == 1:
			k[i + 1][2] = str(abs(int(k[i + 1][2]) - 1))
			k[i - 1][2] = str(abs(int(k[i - 1][2]) - 1))
		else:
			k[i - 1][2] = str(abs(int(k[i - 1][2]) - 1))
for h in k:
	print(''.join(h))


mat = []
for i in range(3):
	mat.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		mat[i][j] = mat[i][j] % 2
ans = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
n = 3
for i in range(3):
	for j in range(3):
		if mat[i][j] != 0:
			ans[i][j] = not ans[i][j]
			if j + 1 < n:
				ans[i][j + 1] = not ans[i][j + 1]
			if j - 1 >= 0:
				ans[i][j - 1] = not ans[i][j - 1]
			if i + 1 < n:
				ans[i + 1][j] = not ans[i + 1][j]
			if i - 1 >= 0:
				ans[i - 1][j] = not ans[i - 1][j]
for i in range(3):
	for j in range(3):
		if ans[i][j] == False:
			ans[i][j] = 0
		if ans[i][j] == True:
			ans[i][j] = 1
		print(ans[i][j], end='')
	print()


lamps = [list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split()))]
lamps1 = [[lamps[0][0] + lamps[0][1] + lamps[1][0], lamps[0][1] + lamps[0][0] + lamps[0][2] + lamps[1][1], lamps[0][2] + lamps[0][1] + lamps[1][2]]]
lamps1.append([lamps[1][0] + lamps[0][0] + lamps[2][0] + lamps[1][1], lamps[0][1] + lamps[1][0] + lamps[1][1] + lamps[1][2] + lamps[2][1], lamps[1][2] + lamps[1][1] + lamps[0][2] + lamps[2][2]])
lamps1.append([lamps[2][0] + lamps[1][0] + lamps[2][1], lamps[2][1] + lamps[2][0] + lamps[2][2] + lamps[1][1], lamps[2][2] + lamps[2][1] + lamps[1][2]])
for i in range(3):
	for j in range(3):
		if lamps1[i][j] % 2 == 0:
			lamps[i][j] = 1
		else:
			lamps[i][j] = 0
print(*lamps[0], sep='')
print(*lamps[1], sep='')
print(*lamps[2], sep='')


A = [list(map(int, input().split())) for _ in range(3)]
B = [[1] * 3 for _ in range(3)]
for i in range(3):
	for j in range(3):
		B[i][j] ^= sum((A[x][y] for (x, y) in ((i - 1, j), (i, j - 1), (i, j), (i, j + 1), (i + 1, j)) if 0 <= x <= 2 and 0 <= y <= 2)) & 1
for row in B:
	print(*row, sep='')


x = [[1, 1, 1] for _ in range(3)]
y = [[*map(lambda x: int(x) % 2, input().split())] for _ in range(3)]
for i in range(3):
	for j in range(3):
		if y[i][j]:
			x[i][j] = 1 - x[i][j]
			if i < 2:
				x[i + 1][j] = 1 - x[i + 1][j]
			if j < 2:
				x[i][j + 1] = 1 - x[i][j + 1]
			if i > 0:
				x[i - 1][j] = 1 - x[i - 1][j]
			if j > 0:
				x[i][j - 1] = 1 - x[i][j - 1]
print('\n'.join([''.join(map(str, a)) for a in x]))


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


a = [0, 1, 2]
a[0] = [int(i) for i in input().split()]
a[1] = [int(i) for i in input().split()]
a[2] = [int(i) for i in input().split()]
b = []
b.append(a[0][0] + a[0][1] + a[1][0])
b.append(a[0][0] + a[0][1] + a[0][2] + a[1][1])
b.append(a[0][2] + a[0][1] + a[1][2])
b.append(a[0][0] + a[1][0] + a[1][1] + a[2][0])
b.append(a[0][1] + a[1][0] + a[1][1] + a[1][2] + a[2][1])
b.append(a[0][2] + a[1][1] + a[1][2] + a[2][2])
b.append(a[1][0] + a[2][0] + a[2][1])
b.append(a[1][1] + a[2][0] + a[2][1] + a[2][2])
b.append(a[1][2] + a[2][1] + a[2][2])
for i in range(len(b)):
	if b[i] % 2 == 0:
		b[i] = '1'
	else:
		b[i] = '0'
print(''.join(b[:3]))
print(''.join(b[3:6]))
print(''.join(b[6:]))


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


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

def add(i, j, w):
	if 2 >= i >= 0 and 2 >= j >= 0:
		b[i][j] += w
for i in range(3):
	for j in range(3):
		add(i, j, a[i][j])
		add(i - 1, j, a[i][j])
		add(i + 1, j, a[i][j])
		add(i, j + 1, a[i][j])
		add(i, j - 1, a[i][j])
for i in range(3):
	print(''.join(map(str, [[0, 1][b[i][j] % 2] for j in range(3)])))


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)
	for i in range(3):
		for j in range(3):
			lights[i][j] = str(lights[i][j])
	for i in range(3):
		print(''.join(lights[i]))
test()


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


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


a = [[True] * 3 for i in range(3)]
m = []
for i in range(3):
	m.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		if m[i][j] % 2 == 0:
			continue
		aff = [(i, j)]
		if i != 2:
			aff.append((i + 1, j))
		if i != 0:
			aff.append((i - 1, j))
		if j != 2:
			aff.append((i, j + 1))
		if j != 0:
			aff.append((i, j - 1))
		for pt in aff:
			a[pt[0]][pt[1]] = not a[pt[0]][pt[1]]
for r in range(3):
	print(''.join(('1' if d else '0' for d in a[r])))


grid = [[] for _ in range(3)]
grid[0] = list(map(int, input().split()))
grid[1] = list(map(int, input().split()))
grid[2] = list(map(int, input().split()))

def get(g, x, y):
	if x < 0 or y < 0 or x > 2 or (y > 2):
		return 0
	return g[x][y]
for r in range(3):
	res = ''
	for c in range(3):
		res += str((1 + get(grid, r, c) + get(grid, r, c + 1) + get(grid, r, c - 1) + get(grid, r + 1, c) + get(grid, r - 1, c)) % 2)
	print(res)


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


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


grid = [[1] * 5 for i in range(5)]
for i in range(1, 4):
	for (j, k) in zip([1, 2, 3], map(int, input().split())):
		for (n, m) in ([1, 0], [-1, 0], [0, 1], [0, -1], [0, 0]):
			grid[i + n][j + m] += k
for i in range(1, 4):
	for k in range(1, 4):
		print(grid[i][k] % 2, end='')
	print()


n = [] * 3
li = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for _ in range(3):
	c = list(map(int, input().split()))
	n.append(c)
for i in range(3):
	for j in range(3):
		if n[i][j] % 2 != 0:
			li[i][j] = abs(li[i][j] - 1)
			if i == 0:
				li[i + 1][j] = abs(li[i + 1][j] - 1)
			if i == 2:
				li[i - 1][j] = abs(li[i - 1][j] - 1)
			if j == 0:
				li[i][j + 1] = abs(li[i][j + 1] - 1)
			if j == 2:
				li[i][j - 1] = abs(li[i][j - 1] - 1)
			if j == 1:
				li[i][j + 1] = abs(li[i][j + 1] - 1)
				li[i][j - 1] = abs(li[i][j - 1] - 1)
			if i == 1:
				li[i + 1][j] = abs(li[i + 1][j] - 1)
				li[i - 1][j] = abs(li[i - 1][j] - 1)
for i in range(3):
	for j in range(3):
		print(li[i][j], end='')
	print('')


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]
		if s % 2 == 0:
			ans += '1'
		else:
			ans += '0'
	print(ans)


x = [[0, 1, 3], [0, 1, 2, 4], [1, 2, 5], [0, 3, 4, 6], [1, 3, 4, 5, 7], [2, 4, 5, 8], [3, 6, 7], [4, 6, 7, 8], [5, 7, 8]]
ans = [1, 1, 1, 1, 1, 1, 1, 1, 1]
y = []
for i in range(3):
	z = list(map(int, input().split()))
	(z[0], z[1], z[2]) = (z[0] % 2, z[1] % 2, z[2] % 2)
	y.extend(z)
for i in range(9):
	if y[i] == 1:
		for k in x[i]:
			ans[k] = (ans[k] + 1) % 2
print(ans[0], ans[1], ans[2], sep='')
print(ans[3], ans[4], ans[5], sep='')
print(ans[6], ans[7], ans[8], sep='')


inp1 = str(input())
inp2 = str(input())
inp3 = str(input())
inp1 = inp1.split()
inp1 = list(map(int, inp1))
inp2 = inp2.split()
inp2 = list(map(int, inp2))
inp3 = inp3.split()
inp3 = list(map(int, inp3))
a = int(inp1[0])
b = int(inp1[1])
c = int(inp1[2])
d = int(inp2[0])
e = int(inp2[1])
f = int(inp2[2])
g = int(inp3[0])
h = int(inp3[1])
i = int(inp3[2])
a %= 2
b %= 2
c %= 2
d %= 2
e %= 2
f %= 2
g %= 2
h %= 2
i %= 2
a2 = 1
b2 = 1
c2 = 1
d2 = 1
e2 = 1
f2 = 1
g2 = 1
h2 = 1
i2 = 1
if a == 1:
	a2 += 1
	b2 += 1
	d2 += 1
if b == 1:
	a2 += 1
	b2 += 1
	c2 += 1
	e2 += 1
if c == 1:
	b2 += 1
	c2 += 1
	f2 += 1
if d == 1:
	a2 += 1
	d2 += 1
	e2 += 1
	g2 += 1
if e == 1:
	b2 += 1
	d2 += 1
	e2 += 1
	f2 += 1
	h2 += 1
if f == 1:
	c2 += 1
	e2 += 1
	f2 += 1
	i2 += 1
if g == 1:
	d2 += 1
	g2 += 1
	h2 += 1
if h == 1:
	e2 += 1
	g2 += 1
	h2 += 1
	i2 += 1
if i == 1:
	f2 += 1
	h2 += 1
	i2 += 1
a2 %= 2
b2 %= 2
c2 %= 2
d2 %= 2
e2 %= 2
f2 %= 2
g2 %= 2
h2 %= 2
i2 %= 2
print(str(a2) + str(b2) + str(c2) + '\n' + str(d2) + str(e2) + str(f2) + '\n' + str(g2) + str(h2) + str(i2))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	aa = [LI() for _ in range(3)]
	rr = [[0] * 3 for _ in range(3)]
	for i in range(3):
		for j in range(3):
			t = aa[i][j] % 2
			for (di, dj) in dd:
				ni = i + di
				nj = j + dj
				if ni < 0 or ni > 2 or nj < 0 or (nj > 2):
					continue
				t += aa[ni][nj] % 2
			rr[i][j] = (t + 1) % 2
	return '\n'.join((''.join(map(str, r)) for r in rr))
print(main())


from sys import stdin
board = None
deltar = [-1, 0, 0, 1]
deltac = [0, -1, 1, 0]

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


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


c = 0
a = []
while c < 3:
	b = input()
	l = b.split()
	a.append(l)
	c += 1
if (int(a[0][0]) + int(a[0][1]) + int(a[1][0])) % 2 == 0:
	print(1, end='')
else:
	print(0, end='')
if (int(a[0][1]) + int(a[0][0]) + int(a[0][2]) + int(a[1][1])) % 2 == 0:
	print(1, end='')
else:
	print(0, end='')
if (int(a[0][1]) + int(a[0][2]) + int(a[1][2])) % 2 == 0:
	print(1)
else:
	print(0)
if (int(a[0][0]) + int(a[1][0]) + int(a[1][1]) + int(a[2][0])) % 2 == 0:
	print(1, end='')
else:
	print(0, end='')
if (int(a[1][1]) + int(a[1][0]) + int(a[2][1]) + int(a[1][2]) + int(a[0][1])) % 2 == 0:
	print(1, end='')
else:
	print(0, end='')
if (int(a[1][2]) + int(a[0][2]) + int(a[1][1]) + int(a[2][2])) % 2 == 0:
	print(1)
else:
	print(0)
if (int(a[2][0]) + int(a[1][0]) + int(a[2][1])) % 2 == 0:
	print(1, end='')
else:
	print(0, end='')
if (int(a[2][1]) + int(a[1][1]) + int(a[2][0]) + int(a[2][2])) % 2 == 0:
	print(1, end='')
else:
	print(0, end='')
if (int(a[2][2]) + int(a[1][2]) + int(a[2][1])) % 2 == 0:
	print(1)
else:
	print(0)


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 = []
	set.append((i, j))
	if i - 1 >= 0:
		set.append((i - 1, j))
	if j + 1 <= 2:
		set.append((i, j + 1))
	if j - 1 >= 0:
		set.append((i, j - 1))
	if i + 1 <= 2:
		set.append((i + 1, j))
	return set
for i in range(3):
	for j in range(3):
		if inputGot[i][j] != 0 and inputGot[i][j] % 2 != 0:
			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='')


def read_int_row():
	return [int(x) for x in input().split()]
l1 = 416
l2 = 464
l3 = 200
l4 = 308
l5 = 186
l6 = 89
l7 = 38
l8 = 23
l9 = 11
lights = [[l1, l2, l3], [l4, l5, l6], [l7, l8, l9]]
base_board = 511
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:])


res = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	arr = input().split(' ')
	for j in range(3):
		val = int(arr[j]) % 2
		if val == 1:
			res[i][j] = 0 if res[i][j] == 1 else 1
			if i + 1 < 3:
				res[i + 1][j] = 0 if res[i + 1][j] == 1 else 1
			if i - 1 > -1:
				res[i - 1][j] = 0 if res[i - 1][j] == 1 else 1
			if j + 1 < 3:
				res[i][j + 1] = 0 if res[i][j + 1] == 1 else 1
			if j - 1 > -1:
				res[i][j - 1] = 0 if res[i][j - 1] == 1 else 1
for i in range(3):
	temp = ''
	for j in range(3):
		temp += str(res[i][j])
	print(temp)


d = {}
for i in range(3):
	l = list(map(int, input().split()))
	for j in range(3):
		k = str(i) + ' ' + str(j)
		d[k] = l[j] % 2
g = {'0 0': 1, '0 1': 1, '0 2': 1, '1 0': 1, '1 1': 1, '1 2': 1, '2 0': 1, '2 1': 1, '2 2': 1}
for x in d:
	aa = x
	if d[x] == 1:
		x = list(map(int, x.split()))
		peechecell = [x[0], x[1] - 1]
		peechecell = ' '.join((str(y) for y in peechecell))
		aagecell = [x[0], x[1] + 1]
		aagecell = ' '.join((str(y) for y in aagecell))
		uparcell = [x[0] - 1, x[1]]
		uparcell = ' '.join((str(y) for y in uparcell))
		neechecell = [x[0] + 1, x[1]]
		neechecell = ' '.join((str(y) for y in neechecell))
		if g[aa] == 1:
			g[aa] = 0
		else:
			g[aa] = 1
		try:
			if g[peechecell] == 1:
				g[peechecell] = 0
			else:
				g[peechecell] = 1
		except Exception as e:
			pass
		try:
			if g[aagecell] == 1:
				g[aagecell] = 0
			else:
				g[aagecell] = 1
		except Exception as e:
			pass
		try:
			if g[neechecell] == 1:
				g[neechecell] = 0
			else:
				g[neechecell] = 1
		except Exception as e:
			pass
		try:
			if g[uparcell] == 1:
				g[uparcell] = 0
			else:
				g[uparcell] = 1
		except Exception as e:
			pass
ii = list(g.values())
for i in range(0, 9, 3):
	s = str(ii[i]) + str(ii[i + 1]) + str(ii[i + 2])
	print(s)


a = [] * 3
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		adj = [a[x][y] for (x, y) in [(i, j + 1), (i, j - 1), (i + 1, j), (i - 1, j), (i, j)] if 0 <= x < 3 and 0 <= y < 3]
		print(1 - int(sum(adj)) % 2, end='')
	print()


a = [[8] * 5 for i in range(5)]
b = [[int(j) for j in input().split()] for i in range(3)]
c = [[1] * 5 for i in range(5)]
(n, k) = (0, 0)
for i in range(1, 4):
	for j in range(1, 4):
		a[i][j] = b[n][k]
		k += 1
	n += 1
	k = 0
for i in range(1, 4):
	for j in range(1, 4):
		if a[i][j] % 2 == 0:
			a[i][j] = 0
		else:
			a[i][j] = 1
for i in range(len(a) - 1):
	for j in range(len(a[i]) - 1):
		if i >= 1 and i <= 3 and (j >= 1) and (j <= 3):
			if a[i][j] % 2 != 0:
				c[i][j] = 1 - c[i][j]
				c[i + 1][j] = 1 - c[i + 1][j]
				c[i - 1][j] = 1 - c[i - 1][j]
				c[i][j + 1] = 1 - c[i][j + 1]
				c[i][j - 1] = 1 - c[i][j - 1]
for i in range(1, 4):
	for j in range(1, 4):
		print(c[i][j], end='')
	print()


A = []
sw = [1, 0]
L = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for _ in range(3):
	A.append(list(map(int, input().split(' '))))
for (p, v) in enumerate(A):
	for (i, j) in enumerate(v):
		if j != 0:
			for _ in range(j):
				L[p][i] = sw[L[p][i]]
				for m in [-1, 1]:
					if p + m > -1:
						try:
							L[p + m][i] = sw[L[p + m][i]]
						except:
							pass
					if i + m > -1:
						try:
							L[p][i + m] = sw[L[p][i + m]]
						except:
							pass
for i in L:
	print(''.join((str(l) for l in i)))


u = list(map(int, input().split()))
m = list(map(int, input().split()))
l = list(map(int, input().split()))
(a, b, c) = ([0, 0, 0], [0, 0, 0], [0, 0, 0])
a[0] = 1 - (u[0] + m[0] + u[1]) % 2
a[1] = 1 - (u[0] + u[1] + u[2] + m[1]) % 2
a[2] = 1 - (u[1] + u[2] + m[2]) % 2
b[0] = 1 - (m[0] + u[0] + l[0] + m[1]) % 2
b[1] = 1 - (m[0] + m[1] + m[2] + u[1] + l[1]) % 2
b[2] = 1 - (m[2] + m[1] + u[2] + l[2]) % 2
c[0] = 1 - (l[0] + l[1] + m[0]) % 2
c[1] = 1 - (l[0] + l[1] + l[2] + m[1]) % 2
c[2] = 1 - (l[2] + l[1] + m[2]) % 2
print(*a, sep='')
print(*b, sep='')
print(*c, sep='')


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


def main():
	m = []
	for i in range(3):
		l = [int(x) % 2 for x in input().split()]
		m.append(l)
	ml = [[1 for i in range(3)] for j in range(3)]
	for i in range(3):
		for j in range(3):
			if m[i][j] == 1:
				ml[i][j] = (ml[i][j] + 1) % 2
				if i - 1 >= 0:
					ml[i - 1][j] = (ml[i - 1][j] + 1) % 2
				if i + 1 < 3:
					ml[i + 1][j] = (ml[i + 1][j] + 1) % 2
				if j + 1 < 3:
					ml[i][j + 1] = (ml[i][j + 1] + 1) % 2
				if j - 1 >= 0:
					ml[i][j - 1] = (ml[i][j - 1] + 1) % 2
	for i in ml:
		for j in i:
			print(j, end='')
		print()
main()


lst = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
a = [list(map(int, input().split())) for i in range(3)]
for i in range(3):
	for j in range(3):
		if i == 0 and j == 0:
			res = a[i][j] + a[i + 1][j] + a[i][j + 1]
			if res % 2 == 0:
				lst[i][j] = 1
			else:
				lst[i][j] = 0
		elif i == 0 and j == 1:
			res = a[i][j] + a[i][j - 1] + a[i][j + 1] + a[i + 1][j]
			if res % 2 == 0:
				lst[i][j] = 1
			else:
				lst[i][j] = 0
		elif i == 0 and j == 2:
			res = a[i][j] + a[i][j - 1] + a[i + 1][j]
			if res % 2 == 0:
				lst[i][j] = 1
			else:
				lst[i][j] = 0
		elif i == 1 and j == 0:
			res = a[i][j] + a[i][j + 1] + a[i - 1][j] + a[i + 1][j]
			if res % 2 == 0:
				lst[i][j] = 1
			else:
				lst[i][j] = 0
		elif i == 1 and j == 1:
			res = a[i][j] + a[i][j + 1] + a[i][j - 1] + a[i - 1][j] + a[i + 1][j]
			if res % 2 == 0:
				lst[i][j] = 1
			else:
				lst[i][j] = 0
		elif i == 1 and j == 2:
			res = a[i][j] + a[i - 1][j] + a[i + 1][j] + a[i][j - 1]
			if res % 2 == 0:
				lst[i][j] = 1
			else:
				lst[i][j] = 0
		elif i == 2 and j == 0:
			res = a[i][j] + a[i][j + 1] + a[i - 1][j]
			if res % 2 == 0:
				lst[i][j] = 1
			else:
				lst[i][j] = 0
		elif i == 2 and j == 1:
			res = a[i][j] + a[i - 1][j] + a[i][j - 1] + a[i][j + 1]
			if res % 2 == 0:
				lst[i][j] = 1
			else:
				lst[i][j] = 0
		elif i == 2 and j == 2:
			res = a[i][j] + a[i - 1][j] + a[i][j - 1]
			if res % 2 == 0:
				lst[i][j] = 1
			else:
				lst[i][j] = 0
for i in range(3):
	for j in range(3):
		print(lst[i][j], end='')
	print()


lso = []
for r in range(3):
	x = list(map(int, input().split()))
	lso.append(x)
ls = [['1', '1', '1'], ['1', '1', '1'], ['1', '1', '1']]
x = lambda p: '1' if p == '0' else '0'
for i in range(3):
	for j in range(3):
		if lso[i][j] % 2 != 0:
			ls[i][j] = x(ls[i][j])
			if i > 0:
				ls[i - 1][j] = x(ls[i - 1][j])
			if i < 2:
				ls[i + 1][j] = x(ls[i + 1][j])
			if j > 0:
				ls[i][j - 1] = x(ls[i][j - 1])
			if j < 2:
				ls[i][j + 1] = x(ls[i][j + 1])
print(''.join(ls[0]))
print(''.join(ls[1]))
print(''.join(ls[2]))


import sys
n = 3
mat = []
for i in range(n):
	t = list(map(int, input().split()))
	mat.append(t)
ans = [[1 for i in range(3)] for j in range(3)]
for i in range(3):
	for j in range(3):
		s = mat[i][j]
		if j - 1 >= 0:
			s += mat[i][j - 1]
		if j + 1 < 3:
			s += mat[i][j + 1]
		if i - 1 >= 0:
			s += mat[i - 1][j]
		if i + 1 < 3:
			s += mat[i + 1][j]
		if s % 2 != 0:
			ans[i][j] = 0
for i in ans:
	for j in i:
		print(j, end='')
	print()


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


def lightsOut():
	l = []
	for i in range(3):
		s = [int(x) for x in input().split()]
		l.append(s)
	i = 0
	ans = [[1, 1, 1] for i in range(3)]
	while i < 3:
		j = 0
		while j < 3:
			oc = 0
			if l[i][j] % 2 != 0:
				oc = oc + l[i][j]
			if i + 1 < 3:
				if l[i + 1][j] % 2 != 0:
					oc = oc + l[i + 1][j]
			if i - 1 >= 0:
				if l[i - 1][j] % 2 != 0:
					oc = oc + l[i - 1][j]
			if j + 1 < 3:
				if l[i][j + 1] % 2 != 0:
					oc = oc + l[i][j + 1]
			if j - 1 >= 0:
				if l[i][j - 1] != 0:
					oc = oc + l[i][j - 1]
			if oc % 2 == 0:
				ans[i][j] = 1
			else:
				ans[i][j] = 0
			j = j + 1
		i = i + 1
	for i in range(3):
		print(ans[i][0], ans[i][1], ans[i][2], sep='')
lightsOut()


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


matrix = []
matrix.append([int(num) for num in input().split()])
matrix.append([int(num) for num in input().split()])
matrix.append([int(num) for num in input().split()])
result = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
row = 0
while row < 3:
	col = 0
	while col < 3:
		if matrix[row][col] % 2 == 1:
			result[row][col] = 1 if result[row][col] == 0 else 0
			if row - 1 >= 0 and row - 1 <= 2 and (col >= 0) and (col <= 2):
				result[row - 1][col] = 1 if result[row - 1][col] == 0 else 0
			if row >= 0 and row <= 2 and (col - 1 >= 0) and (col - 1 <= 2):
				result[row][col - 1] = 1 if result[row][col - 1] == 0 else 0
			if row + 1 >= 0 and row + 1 <= 2 and (col >= 0) and (col <= 2):
				result[row + 1][col] = 1 if result[row + 1][col] == 0 else 0
			if row >= 0 and row <= 2 and (col + 1 >= 0) and (col + 1 <= 2):
				result[row][col + 1] = 1 if result[row][col + 1] == 0 else 0
		col += 1
	row += 1
for row in result:
	for num in row:
		print(num, end='')
	print()


def matsum(a):
	b = [[0 for i in range(5)] for j in range(5)]
	for i in range(1, 4):
		for j in range(1, 4):
			b[i][j] = (a[i][j] + a[i + 1][j] + a[i - 1][j] + a[i][j + 1] + a[i][j - 1]) % 2
	return b
a = [[0 for i in range(5)] for j in range(5)]
for i in range(1, 4):
	b = [int(i) for i in input().split()]
	a[i][1:4] = b
b = matsum(a)
for i in range(1, 4):
	c = ''
	for j in range(1, 4):
		if b[i][j] == 1:
			c = c + '0'
		else:
			c = c + '1'
	print(c)


(a1, a2, a3) = [int(x) for x in input().split(' ')]
(b1, b2, b3) = [int(x) for x in input().split(' ')]
(c1, c2, c3) = [int(x) for x in input().split(' ')]
print(1, end='') if (a1 + a2 + b1) % 2 == 0 else print(0, end='')
print(1, end='') if (a1 + a2 + b2 + a3) % 2 == 0 else print(0, end='')
print(1) if (a2 + b3 + a3) % 2 == 0 else print(0)
print(1, end='') if (a1 + b2 + b1 + c1) % 2 == 0 else print(0, end='')
print(1, end='') if (a2 + b2 + b1 + c2 + b3) % 2 == 0 else print(0, end='')
print(1) if (a3 + b3 + b2 + c3) % 2 == 0 else print(0)
print(1, end='') if (c1 + b1 + c2) % 2 == 0 else print(0, end='')
print(1, end='') if (c1 + b2 + c3 + c2) % 2 == 0 else print(0, end='')
print(1) if (c3 + b3 + c2) % 2 == 0 else print(0)


dp = [list(map(int, input().split())) for i in range(3)]
a1 = (dp[0][0] + dp[0][1] + dp[1][0] + 1) % 2
a2 = (dp[0][1] + dp[0][0] + dp[0][2] + 1 + dp[1][1]) % 2
a3 = (dp[0][2] + dp[0][1] + dp[1][2] + 1) % 2
a4 = (dp[1][0] + dp[0][0] + dp[1][1] + 1 + dp[2][0]) % 2
a5 = (dp[1][1] + dp[1][0] + dp[0][1] + 1 + dp[1][2] + dp[2][1]) % 2
a6 = (dp[1][2] + dp[1][1] + dp[0][2] + 1 + dp[2][2]) % 2
a7 = (dp[2][0] + dp[1][0] + dp[2][1] + 1) % 2
a8 = (dp[2][1] + dp[2][0] + dp[2][2] + 1 + dp[1][1]) % 2
a9 = (dp[2][2] + dp[2][1] + dp[1][2] + 1) % 2
print(str(a1) + str(a2) + str(a3))
print(str(a4) + str(a5) + str(a6))
print(str(a7) + str(a8) + str(a9))


y = [[int(i) for i in input().split()] for j in range(3)]
lit = [[0 for i in range(3)] for j in range(3)]
for i in range(3):
	lit = ''
	for j in range(3):
		count = y[i][j]
		if i > 0:
			count += y[i - 1][j]
		if i < 2:
			count += y[i + 1][j]
		if j > 0:
			count += y[i][j - 1]
		if j < 2:
			count += y[i][j + 1]
		if not count % 2:
			lit += '1'
		else:
			lit += '0'
	print(lit)


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


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

def switch(x, y, n):
	luzes[y][x] = (n + luzes[y][x]) % 2
	if x > 0:
		luzes[y][x - 1] = (n + luzes[y][x - 1]) % 2
	if x < 2:
		luzes[y][x + 1] = (n + luzes[y][x + 1]) % 2
	if y > 0:
		luzes[y - 1][x] = (n + luzes[y - 1][x]) % 2
	if y < 2:
		luzes[y + 1][x] = (n + luzes[y + 1][x]) % 2
for i in range(3):
	linha = [int(x) for x in input().split()]
	for j in range(3):
		if linha[j] != 0:
			switch(j, i, linha[j])
for l in luzes:
	print(*l, sep='')


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

def main() -> int:
	lights = []
	results = [['', '', ''], ['', '', ''], ['', '', '']]
	for _ in range(3):
		lights.append([int(word) for word in input().split()])
	for i in range(3):
		for j in range(3):
			temp = lights[i][j] + (lights[i - 1][j] if i > 0 else 0) + (lights[i][j - 1] if j > 0 else 0) + (lights[i + 1][j] if i < 2 else 0) + (lights[i][j + 1] if j < 2 else 0)
			results[i][j] = str(1 - temp % 2)
	result_strings = [''.join(listi) for listi in results]
	print('\n'.join(result_strings))
	return 0

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


matrix = [[int(i) for i in input().split()], [int(j) for j in input().split()], [int(k) for k in input().split()]]
sums_matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
results_matrix = [['1', '1', '1'], ['1', '1', '1'], ['1', '1', '1']]
for y in range(0, 3):
	for x in range(0, 3):
		sums_matrix[y][x] += matrix[y][x]
		if y < 2:
			sums_matrix[y][x] += matrix[y + 1][x]
			sums_matrix[y + 1][x] += matrix[y][x]
		if x < 2:
			sums_matrix[y][x] += matrix[y][x + 1]
			sums_matrix[y][x + 1] += matrix[y][x]
		results_matrix[y][x] = '1' if sums_matrix[y][x] % 2 == 0 else '0'
	print(''.join(results_matrix[y]))


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


inp = []
for x in range(3):
	temp = input().split(' ')
	temp = [int(i) for i in temp]
	inp.append(temp)
out = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
out[0][0] = str((1 + inp[0][0] + inp[0][1] + inp[1][0]) % 2)
out[0][1] = str((1 + inp[0][0] + inp[0][1] + inp[0][2] + inp[1][1]) % 2)
out[0][2] = str((1 + inp[0][1] + inp[0][2] + inp[1][2]) % 2)
out[1][0] = str((1 + inp[0][0] + inp[1][0] + inp[2][0] + inp[1][1]) % 2)
out[1][1] = str((1 + inp[0][1] + inp[1][0] + inp[1][1] + inp[1][2] + inp[2][1]) % 2)
out[1][2] = str((1 + inp[0][2] + inp[1][1] + inp[1][2] + inp[2][2]) % 2)
out[2][0] = str((1 + inp[1][0] + inp[2][0] + inp[2][1]) % 2)
out[2][1] = str((1 + inp[1][1] + inp[2][0] + inp[2][1] + inp[2][2]) % 2)
out[2][2] = str((1 + inp[1][2] + inp[2][1] + inp[2][2]) % 2)
for i in range(3):
	print(''.join(out[i]))


matrix = []
for i in range(3):
	matrix.append(list(map(int, input().split(' '))))
answer = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	for j in range(3):
		if matrix[i][j] % 2 == 0:
			continue
		answer[i][j] += 1
		answer[i][j] %= 2
		if j + 1 < 3:
			answer[i][j + 1] += 1
			answer[i][j + 1] %= 2
		if j - 1 >= 0:
			answer[i][j - 1] += 1
			answer[i][j - 1] %= 2
		if i + 1 < 3:
			answer[i + 1][j] += 1
			answer[i + 1][j] %= 2
		if i - 1 >= 0:
			answer[i - 1][j] += 1
			answer[i - 1][j] %= 2
for i in range(3):
	print(str(answer[i][0]) + str(answer[i][1]) + str(answer[i][2]))


def flip(i, j):
	if arr[i][j] == 1:
		arr[i][j] = 0
	else:
		arr[i][j] = 1
global arr
arr = []
for n in range(3):
	(a, b, c) = (1, 1, 1)
	arr.append([a, b, c])
myarray = []
for i in range(3):
	temp = [int(x) % 2 for x in input().split()]
	myarray.append(temp)
for i in range(len(myarray)):
	for j in range(len(myarray[i])):
		if myarray[i][j] == 1:
			flip(i, j)
			if i - 1 >= 0:
				flip(i - 1, j)
			if i + 1 <= 2:
				flip(i + 1, j)
			if j + 1 <= 2:
				flip(i, j + 1)
			if j - 1 >= 0:
				flip(i, j - 1)
for p in range(len(arr)):
	for q in range(len(arr[p])):
		print(arr[p][q], end='')
	print()


def isValid(x, y):
	if (x >= 0) & (y >= 0) & (x < 3) & (y < 3):
		return True
	return False

def main():
	lights = []
	for x in range(3):
		lights.append([0, 0, 0])
	flicks = []
	for i in range(3):
		flicks.append([int(x) for x in input().split()])
	for i in range(3):
		for j in range(3):
			if flicks[i][j] != 0:
				lights[i][j] += flicks[i][j]
				if isValid(i, j - 1):
					lights[i][j - 1] += flicks[i][j]
				if isValid(i, j + 1):
					lights[i][j + 1] += flicks[i][j]
				if isValid(i - 1, j):
					lights[i - 1][j] += flicks[i][j]
				if isValid(i + 1, j):
					lights[i + 1][j] += flicks[i][j]
	for i in range(3):
		for j in range(3):
			if lights[i][j] % 2 != 0:
				print(0, end='')
			else:
				print(1, end='')
		print()
main()


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


def tog(ans, i, j):
	if ans[i][j] == 'n':
		ans[i][j] = '0'
	elif ans[i][j] == '0':
		ans[i][j] = '1'
	else:
		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)
			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)
		elif ans[i][j] == 'n':
			ans[i][j] = '1'
for row in ans:
	print(''.join(row))


def get_neighbours(x, y):
	result = []
	ils = [0, 1, -1, 0]
	jls = [1, 0, 0, -1]
	for (i, j) in zip(ils, jls):
		if 0 <= x + i < 3 and 0 <= y + j < 3:
			result.append((x + i, y + j))
	return result
actions = []
for i in range(3):
	actions.append(list(map(int, input().split())))
matr = [[1, 1, 1] for i in range(3)]
for i in range(3):
	for j in range(3):
		if actions[i][j] % 2 != 0:
			matr[i][j] = 0 if matr[i][j] else 1
			neigh = get_neighbours(i, j)
			for (x, y) in neigh:
				matr[x][y] = 0 if matr[x][y] else 1
for i in range(3):
	print(''.join(map(str, matr[i])))


def switch(a):
	return 0 if a > 0 else 1
arr = []
for i in range(3):
	k = list(map(int, input().split()))
	k = [i % 2 for i in k]
	arr.append(k)
lis = [[1, 1, 1] for _ in range(3)]
for i in range(3):
	for j in range(3):
		if arr[i][j] == 0:
			pass
		else:
			check = [(i, j), (i + 1, j), (i - 1, j), (i, j + 1), (i, j - 1)]
			for (x, y) in check:
				if x < 0 or x > 2 or y < 0 or (y > 2):
					pass
				else:
					lis[x][y] = switch(lis[x][y])
for i in lis:
	print(''.join(map(str, i)))


import sys
matrix = []
for i in range(3):
	row = list(map(int, sys.stdin.readline().split()))
	matrix.append(row)
output_matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

def check(i, j):
	return 0 <= i <= 2 and 0 <= j <= 2
for i in range(3):
	for j in range(3):
		output = matrix[i][j]
		if check(i, j + 1):
			output += matrix[i][j + 1]
		if check(i, j - 1):
			output += matrix[i][j - 1]
		if check(i + 1, j):
			output += matrix[i + 1][j]
		if check(i - 1, j):
			output += matrix[i - 1][j]
		output_matrix[i][j] = (1 + output) % 2
for row in output_matrix:
	sys.stdout.write(''.join(map(str, row)) + '\n')


G = [[1] * 5 for i in range(5)]
D = [(0, 0), (-1, 0), (1, 0), (0, -1), (0, 1)]

def toggle(i, j):
	for d in D:
		G[i + d[0]][j + d[1]] = 1 - G[i + d[0]][j + d[1]]
for i in range(1, 4):
	n = list(map(int, input().split()))
	for j in range(1, 4):
		if n[j - 1] % 2 == 1:
			toggle(i, j)
for i in range(1, 4):
	for j in range(1, 4):
		print(G[i][j], end='')
	print()


def rl():
	return [int(x) for x in input().split(' ')]
matrix = [rl(), rl(), rl()]

def sum_adjacent(matrix, y0, x0):
	return sum((matrix[y][x] for x in range(x0 - 1, x0 + 2) for y in range(y0 - 1, y0 + 2) if x >= 0 and x <= 2 and (y >= 0) and (y <= 2) and (abs(x - x0) + abs(y - y0) <= 1)))
result = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for y in range(3):
	for x in range(3):
		print((sum_adjacent(matrix, y, x) + 1) % 2, end='')
	print()


l1 = input().split()
l2 = input().split()
l3 = input().split()
l1 = [int(i) for i in l1]
l2 = [int(i) for i in l2]
l3 = [int(i) for i in l3]
m = [l1, l2, l3]
n = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
p = [['0', '0', '0'], ['0', '0', '0'], ['0', '0', '0']]
n[0][0] += m[0][0]
n[0][1] += m[0][0]
n[1][0] += m[0][0]
n[0][0] += m[0][1]
n[0][1] += m[0][1]
n[0][2] += m[0][1]
n[1][1] += m[0][1]
n[0][2] += m[0][2]
n[0][1] += m[0][2]
n[1][2] += m[0][2]
n[0][0] += m[1][0]
n[1][0] += m[1][0]
n[1][1] += m[1][0]
n[2][0] += m[1][0]
n[0][1] += m[1][1]
n[2][1] += m[1][1]
n[1][2] += m[1][1]
n[1][0] += m[1][1]
n[1][1] += m[1][1]
n[0][2] += m[1][2]
n[1][1] += m[1][2]
n[1][2] += m[1][2]
n[2][2] += m[1][2]
n[2][0] += m[2][0]
n[2][1] += m[2][0]
n[1][0] += m[2][0]
n[2][0] += m[2][1]
n[2][1] += m[2][1]
n[2][2] += m[2][1]
n[1][1] += m[2][1]
n[2][2] += m[2][2]
n[2][1] += m[2][2]
n[1][2] += m[2][2]
for i in range(3):
	for j in range(3):
		if n[i][j] % 2 == 0:
			p[i][j] = '1'
for i in range(3):
	print(p[i][0] + p[i][1] + p[i][2])


matrix = [[1] * 3 for i in range(3)]
togg = [[0] * 3 for i in range(3)]
for i in range(3):
	togg[i] = list(map(int, input().split()))
for i in range(3):
	for j in range(3):
		if togg[i][j] % 2 != 0:
			matrix[i][j] = int(not matrix[i][j])
			if i - 1 >= 0:
				matrix[i - 1][j] = int(not matrix[i - 1][j])
			if i + 1 < 3:
				matrix[i + 1][j] = int(not matrix[i + 1][j])
			if j + 1 < 3:
				matrix[i][j + 1] = int(not matrix[i][j + 1])
			if j - 1 >= 0:
				matrix[i][j - 1] = int(not matrix[i][j - 1])
matrix = [map(str, l) for l in matrix]
result = []
for i in range(3):
	result.append(''.join(matrix[i]))
for i in range(3):
	print(result[i])


(a, b) = ([], [])

def check(value):
	if value == '1':
		return '0'
	else:
		return '1'
for i in range(3):
	temp = list(input().split())
	a.append(temp)
	b.append(['1', '1', '1'])
for i in range(3):
	for j in range(3):
		if int(a[i][j]) % 2 == 0:
			continue
		else:
			b[i][j] = check(b[i][j])
			if i - 1 >= 0:
				b[i - 1][j] = check(b[i - 1][j])
			if i + 1 < 3:
				b[i + 1][j] = check(b[i + 1][j])
			if j + 1 < 3:
				b[i][j + 1] = check(b[i][j + 1])
			if j - 1 >= 0:
				b[i][j - 1] = check(b[i][j - 1])
for i in range(3):
	print(''.join(b[i]))


a = [[int(x) % 2 for x in input().split()] for i in range(3)]
b = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
	for j in range(3):
		s = a[i][j]
		if i > 0:
			s += a[i - 1][j]
		if i < 2:
			s += a[i + 1][j]
		if j > 0:
			s += a[i][j - 1]
		if j < 2:
			s += a[i][j + 1]
		b[i][j] = (s + 1) % 2
for e in b:
	print(''.join(map(str, e)))


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


def single_integer():
	return int(input())

def multi_integer():
	return map(int, input().split())

def string():
	return input()

def multi_string():
	return input().split()
lights_list = list()
new_light = list()
for i in range(3):
	lights_list.append(tuple(multi_integer()))
for i in range(3):
	temp = list()
	for j in range(3):
		ans = 0
		if i == 0:
			if j == 0:
				ans = lights_list[i][j] + lights_list[i + 1][j] + lights_list[i][j + 1]
			elif j == 2:
				ans = lights_list[i][j] + lights_list[i + 1][j] + lights_list[i][j - 1]
			else:
				ans = lights_list[i][j] + lights_list[i][j + 1] + lights_list[i][j - 1] + lights_list[i + 1][j]
		elif i == 2:
			if j == 0:
				ans = lights_list[i][j] + lights_list[i - 1][j] + lights_list[i][j + 1]
			elif j == 2:
				ans = lights_list[i][j] + lights_list[i - 1][j] + lights_list[i][j - 1]
			else:
				ans = lights_list[i][j] + lights_list[i][j + 1] + lights_list[i][j - 1] + lights_list[i - 1][j]
		elif j == 0:
			ans = lights_list[i][j] + lights_list[i - 1][j] + lights_list[i][j + 1] + lights_list[i + 1][j]
		elif j == 2:
			ans = lights_list[i][j] + lights_list[i - 1][j] + lights_list[i][j - 1] + lights_list[i + 1][j]
		else:
			ans = lights_list[i][j] + lights_list[i][j + 1] + lights_list[i][j - 1] + lights_list[i - 1][j] + lights_list[i + 1][j]
		if ans % 2 == 0:
			temp.append(1)
		else:
			temp.append(0)
	new_light.append(temp)
for i in new_light:
	print(''.join((str(k) for k in i)))


l = []
for _ in range(3):
	l.append(list(map(int, input().split())))
lf = l[:]
row2 = [l[0][i] + l[2][i] for i in range(3)]
row = [l[1][i] for i in range(3)]
col = [l[i][1] for i in range(3)]
col2 = [l[i][0] + l[i][2] for i in range(3)]
for i in range(3):
	lf[1][i] += row2[i]
	lf[i][1] += col2[i]
	lf[0][i] += row[i]
	lf[2][i] += row[i]
	lf[i][0] += col[i]
	lf[i][2] += col[i]
for i in range(3):
	for j in range(3):
		if lf[i][j] % 2 == 0:
			lf[i][j] = '1'
		else:
			lf[i][j] = '0'
for i in range(3):
	print(''.join(lf[i]))


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

def isvalid(i, j):
	return (i >= 0 and i < 3) and (j >= 0 and j < 3)
for i in range(3):
	for j in range(3):
		if a[i][j] % 2 != 0:
			if c[i][j] == 1:
				c[i][j] = 0
			else:
				c[i][j] = 1
			if isvalid(i, j - 1):
				if c[i][j - 1] == 1:
					c[i][j - 1] = 0
				else:
					c[i][j - 1] = 1
			if isvalid(i, j + 1):
				if c[i][j + 1] == 1:
					c[i][j + 1] = 0
				else:
					c[i][j + 1] = 1
			if isvalid(i - 1, j):
				if c[i - 1][j] == 1:
					c[i - 1][j] = 0
				else:
					c[i - 1][j] = 1
			if isvalid(i + 1, j):
				if c[i + 1][j] == 1:
					c[i + 1][j] = 0
				else:
					c[i + 1][j] = 1
for i in range(3):
	print(''.join(list(map(str, c[i]))))


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


a = [[0, *map(int, input().split()), 0] for _ in [0] * 3]
a = [[0] * 5, *a, [0] * 5]
dy = [0, -1, 0, 0, 1]
dx = [0, 0, -1, 1, 0]
for i in range(1, 4):
	print(''.join([str(1 - sum((a[i + y][j + x] for (x, y) in zip(dx, dy))) % 2) for j in range(1, 4)]))


def main():
	pressed = []
	for _ in range(3):
		row = list(map(int, input().split()))
		pressed.append(row)
	lightboard = [[1, 1, 1] for _ in range(3)]
	for i in range(3):
		for j in range(3):
			for _ in range(pressed[i][j]):
				switch(i, j, lightboard)
				switch(i + 1, j, lightboard)
				switch(i - 1, j, lightboard)
				switch(i, j + 1, lightboard)
				switch(i, j - 1, lightboard)
	for i in range(3):
		for j in range(3):
			print(lightboard[i][j], end='')
		print()

def switch(row, col, lightboard):
	if row >= 0 and col >= 0 and (row < 3) and (col < 3):
		lightboard[row][col] = 0 if lightboard[row][col] else 1
main()


a = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
	for j in range(3):
		a[i][j] = a[i][j] % 2
ans = [[1 for i in range(3)] for _ in range(3)]
for i in range(3):
	for j in range(3):
		if a[i][j]:
			for (x, y) in [(0, -1), (0, 1), (1, 0), (-1, 0), (0, 0)]:
				if i + x in range(3) and j + y in range(3):
					ans[i + x][j + y] = not ans[i + x][j + y]
for i in range(3):
	for j in range(3):
		print(int(ans[i][j]), end='')
	print()


lights = [[1 for i in range(3)] for j in range(3)]
inputs = []
for _ in range(3):
	inputs.append(list(map(int, input().split())))
if inputs[0][0] % 2 != 0:
	lights[0][0] = 0
	lights[0][1] = 0
	lights[1][0] = 0
if inputs[0][1] % 2 != 0:
	lights[0][1] = int(not lights[0][1])
	lights[0][0] = int(not lights[0][0])
	lights[0][2] = int(not lights[0][2])
	lights[1][1] = int(not lights[1][1])
if inputs[0][2] % 2 != 0:
	lights[0][1] = int(not lights[0][1])
	lights[0][2] = int(not lights[0][2])
	lights[1][2] = int(not lights[1][2])
if inputs[1][0] % 2 != 0:
	lights[0][0] = int(not lights[0][0])
	lights[1][0] = int(not lights[1][0])
	lights[1][1] = int(not lights[1][1])
	lights[2][0] = int(not lights[2][0])
if inputs[1][1] % 2 != 0:
	lights[1][0] = int(not lights[1][0])
	lights[1][1] = int(not lights[1][1])
	lights[1][2] = int(not lights[1][2])
	lights[0][1] = int(not lights[0][1])
	lights[2][1] = int(not lights[2][1])
if inputs[1][2] % 2 != 0:
	lights[0][2] = int(not lights[0][2])
	lights[1][1] = int(not lights[1][1])
	lights[1][2] = int(not lights[1][2])
	lights[2][2] = int(not lights[2][2])
if inputs[2][0] % 2 != 0:
	lights[2][0] = int(not lights[2][0])
	lights[2][1] = int(not lights[2][1])
	lights[1][0] = int(not lights[1][0])
if inputs[2][1] % 2 != 0:
	lights[2][0] = int(not lights[2][0])
	lights[2][1] = int(not lights[2][1])
	lights[1][1] = int(not lights[1][1])
	lights[2][2] = int(not lights[2][2])
if inputs[2][2] % 2 != 0:
	lights[2][2] = int(not lights[2][2])
	lights[2][1] = int(not lights[2][1])
	lights[1][2] = int(not lights[1][2])
for i in range(3):
	print(*lights[i], sep='')


matrix = []
res = []
for i in range(3):
	l2 = []
	l3 = [1, 1, 1]
	l = list(map(int, input().split()))
	for j in range(3):
		l2.append(l[j] % 2)
	res.append(l3)
	matrix.append(l2)
for i in range(3):
	for j in range(3):
		if matrix[i][j] == 1:
			res[i][j] = 1 - res[i][j]
			if j < 2:
				res[i][j + 1] = 1 - res[i][j + 1]
			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 i > 0:
				res[i - 1][j] = 1 - res[i - 1][j]
for i in range(3):
	print(*res[i], sep='')


s1 = str(input())
s2 = str(input())
s3 = str(input())
l1 = s1.split()
l2 = s2.split()
l3 = s3.split()
v1 = int(l1[0]) + int(l1[1]) + int(l2[0])
v2 = int(l1[0]) + int(l1[1]) + int(l1[2]) + int(l2[1])
v3 = int(l1[2]) + int(l1[1]) + int(l2[2])
v4 = int(l1[0]) + int(l2[0]) + int(l3[0]) + int(l2[1])
v5 = int(l2[0]) + int(l2[1]) + int(l2[2]) + int(l1[1]) + int(l3[1])
v6 = int(l3[2]) + int(l1[2]) + int(l2[2]) + int(l2[1])
v7 = int(l3[0]) + int(l3[1]) + int(l2[0])
v8 = int(l3[2]) + int(l2[1]) + int(l3[1]) + int(l3[0])
v9 = int(l3[2]) + int(l3[1]) + int(l2[2])
r1 = ''
if v1 % 2 == 0:
	r1 += '1'
else:
	r1 += '0'
if v2 % 2 == 0:
	r1 += '1'
else:
	r1 += '0'
if v3 % 2 == 0:
	r1 += '1'
else:
	r1 += '0'
r2 = ''
if v4 % 2 == 0:
	r2 += '1'
else:
	r2 += '0'
if v5 % 2 == 0:
	r2 += '1'
else:
	r2 += '0'
if v6 % 2 == 0:
	r2 += '1'
else:
	r2 += '0'
r3 = ''
if v7 % 2 == 0:
	r3 += '1'
else:
	r3 += '0'
if v8 % 2 == 0:
	r3 += '1'
else:
	r3 += '0'
if v9 % 2 == 0:
	r3 += '1'
else:
	r3 += '0'
print(r1)
print(r2)
print(r3)


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


arr = []
brr = []
for i in range(3):
	arr.append(list(map(int, input().split())))
	brr.append([1, 1, 1])
for i in range(3):
	for j in range(3):
		if arr[i][j] % 2 != 0:
			brr[i][j] = brr[i][j] * -1
			if i > 0:
				brr[i - 1][j] = brr[i - 1][j] * -1
			if i < 2:
				brr[i + 1][j] = brr[i + 1][j] * -1
			if j > 0:
				brr[i][j - 1] = brr[i][j - 1] * -1
			if j < 2:
				brr[i][j + 1] = brr[i][j + 1] * -1
for i in range(3):
	for j in range(3):
		if brr[i][j] == -1:
			brr[i][j] = '0'
		else:
			brr[i][j] = '1'
	print(''.join(brr[i]))


arr = [input().split() for i in range(3)]
brr = [[1 for i in range(3)] for j in range(3)]
for i in range(3):
	for j in range(3):
		if int(arr[i][j]) % 2 == 1:
			brr[i][j] ^= 1
			if i - 1 >= 0:
				brr[i - 1][j] ^= 1
			if j - 1 >= 0:
				brr[i][j - 1] ^= 1
			if i + 1 < 3:
				brr[i + 1][j] ^= 1
			if j + 1 < 3:
				brr[i][j + 1] ^= 1
for i in brr:
	print(''.join([str(j) for j in 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'
for lin in res:
	print(''.join(lin))


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


G = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
P = []
for i in range(3):
	row = [int(i) for i in input().split()]
	P.append(row)
for i in range(3):
	for j in range(3):
		if P[i][j] % 2 == 1:
			G[i][j] = 0 if G[i][j] == 1 else 1
			if i - 1 >= 0:
				G[i - 1][j] = 0 if G[i - 1][j] == 1 else 1
			if i + 1 < 3:
				G[i + 1][j] = 0 if G[i + 1][j] == 1 else 1
			if j - 1 >= 0:
				G[i][j - 1] = 0 if G[i][j - 1] == 1 else 1
			if j + 1 < 3:
				G[i][j + 1] = 0 if G[i][j + 1] == 1 else 1
print(str(G[0][0]) + str(G[0][1]) + str(G[0][2]))
print(str(G[1][0]) + str(G[1][1]) + str(G[1][2]))
print(str(G[2][0]) + str(G[2][1]) + str(G[2][2]))


import math

def sumofno(n):
	summ = 0
	while n > 0:
		summ += n % 10
		n //= 10
	return summ

def get_key(val, lis):
	for (key, value) in lis.items():
		if value == val:
			return key

def reverse(k):
	if k == 1:
		return 0
	else:
		return 1
try:
	t = 1
	ans = []
	for i in range(t):
		a = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]
		c = [[0, 0, 0, 0, 0]]
		for j in range(3):
			b = [0]
			b += list(map(int, input().split()))
			b += [0]
			c.append(b)
		c.append([0, 0, 0, 0, 0])
	for j in range(1, 4):
		for k in range(1, 4):
			if c[j][k] % 2 != 0:
				a[j][k] = reverse(a[j][k])
				a[j][k - 1] = reverse(a[j][k - 1])
				a[j][k + 1] = reverse(a[j][k + 1])
				a[j - 1][k] = reverse(a[j - 1][k])
				a[j + 1][k] = reverse(a[j + 1][k])
	for j in range(1, 4):
		for k in range(1, 4):
			print(a[j][k], end='')
		print('')
except:
	pass


arr = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]

def update():
	for i in range(1, 4):
		for j in range(1, 4):
			arr[i][j] = arr[i][j] % 2
for i in range(1, 4):
	(a, b, c) = map(int, input().split())
	arr[i][1] += a
	arr[i - 1][1] += a
	arr[i + 1][1] += a
	arr[i][2] += a
	arr[i][2] += b
	arr[i - 1][2] += b
	arr[i + 1][2] += b
	arr[i][1] += b
	arr[i][3] += b
	arr[i][3] += c
	arr[i - 1][3] += c
	arr[i + 1][3] += c
	arr[i][2] += c
update()
for i in range(1, 4):
	for j in range(1, 4):
		print(arr[i][j], end='')
	print('')


x = [True, True, True, True, True, True, True, True, True]
for z in (0, 3, 6):
	(a, b, c) = input().split(' ')
	a = int(a)
	b = int(b)
	c = int(c)
	if not a % 2 is 0:
		x[z] = not x[z]
		x[z + 1] = not x[z + 1]
		if z - 3 >= 0:
			x[z - 3] = not x[z - 3]
		if z + 3 <= 8:
			x[z + 3] = not x[z + 3]
	if not b % 2 is 0:
		x[z] = not x[z]
		x[z + 1] = not x[z + 1]
		x[z + 2] = not x[z + 2]
		if z + 1 - 3 >= 0:
			x[z + 1 - 3] = not x[z + 1 - 3]
		if z + 1 + 3 <= 8:
			x[z + 1 + 3] = not x[z + 1 + 3]
	if not c % 2 is 0:
		x[z + 1] = not x[z + 1]
		x[z + 2] = not x[z + 2]
		if z + 2 - 3 >= 0:
			x[z + 2 - 3] = not x[z + 2 - 3]
		if z + 2 + 3 <= 8:
			x[z + 2 + 3] = not x[z + 2 + 3]
g = 0
while g < 9:
	if x[g]:
		print('1', end='')
	else:
		print('0', end='')
	if g is 2 or g is 5:
		print()
	g += 1


from sys import stdin, stdout
from math import gcd, sqrt, floor, ceil
input = stdin.readline

def list_inp(x):
	return list(map(x, input().split()))

def map_inp(x):
	return map(x, input().split())

def lcm(a, b):
	return a * b / gcd(a, b)
mat = [[0, 0, 0, 0, 0]]
for i in range(3):
	x = list_inp(int)
	x = [0] + x + [0]
	mat.append(x)
mat.append([0, 0, 0, 0, 0])
for i in range(1, 4):
	for j in range(1, 4):
		print((mat[i][j - 1] + mat[i - 1][j] + mat[i][j] + mat[i + 1][j] + mat[i][j + 1] + 1) % 2, end='')
	print()


l = [1, 1, 1, 1, 1, 1, 1, 1, 1]
(a, b, c) = map(int, input().split())
if a % 2 == 1:
	l[0] = int(not l[0])
	l[1] = int(not l[1])
	l[3] = int(not l[3])
if b % 2 == 1:
	l[0] = int(not l[0])
	l[1] = int(not l[1])
	l[2] = int(not l[2])
	l[4] = int(not l[4])
if c % 2 == 1:
	l[2] = int(not l[2])
	l[1] = int(not l[1])
	l[5] = int(not l[5])
(a, b, c) = map(int, input().split())
if a % 2 == 1:
	l[0] = int(not l[0])
	l[6] = int(not l[6])
	l[3] = int(not l[3])
	l[4] = int(not l[4])
if b % 2 == 1:
	l[7] = int(not l[7])
	l[1] = int(not l[1])
	l[5] = int(not l[5])
	l[3] = int(not l[3])
	l[4] = int(not l[4])
if c % 2 == 1:
	l[2] = int(not l[2])
	l[8] = int(not l[8])
	l[5] = int(not l[5])
	l[4] = int(not l[4])
(a, b, c) = map(int, input().split())
if a % 2 == 1:
	l[6] = int(not l[6])
	l[7] = int(not l[7])
	l[3] = int(not l[3])
if b % 2 == 1:
	l[6] = int(not l[6])
	l[7] = int(not l[7])
	l[8] = int(not l[8])
	l[4] = int(not l[4])
if c % 2 == 1:
	l[7] = int(not l[7])
	l[8] = int(not l[8])
	l[5] = int(not l[5])
print(str(l[0]) + str(l[1]) + str(l[2]))
print(str(l[3]) + str(l[4]) + str(l[5]))
print(str(l[6]) + str(l[7]) + str(l[8]))


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


ar = []
ar2 = []
a = 0
for i in range(0, 3):
	ar.append(list(map(int, input().rstrip().split())))
for i in range(0, 3):
	for j in range(0, 3):
		if i == 0 and j == 0:
			if (ar[i][j] + ar[i + 1][j] + ar[i][j + 1]) % 2 == 0:
				ar2.append(1)
			else:
				ar2.append(0)
		elif 0 < i < 2 and j == 0:
			if (ar[i][j] + ar[i + 1][j] + ar[i][j + 1] + ar[i - 1][j]) % 2 == 0:
				ar2.append(1)
			else:
				ar2.append(0)
		elif i == 0 and 0 < j < 2:
			if (ar[i][j] + ar[i + 1][j] + ar[i][j + 1] + ar[i][j - 1]) % 2 == 0:
				ar2.append(1)
			else:
				ar2.append(0)
		elif 0 < i < 2 and 0 < j < 2:
			if (ar[i][j] + ar[i + 1][j] + ar[i][j + 1] + ar[i - 1][j] + ar[i][j - 1]) % 2 == 0:
				ar2.append(1)
			else:
				ar2.append(0)
		elif i == 2 and j == 2:
			if (ar[i][j] + ar[i - 1][j] + ar[i][j - 1]) % 2 == 0:
				ar2.append(1)
			else:
				ar2.append(0)
		elif 0 < i < 2 and j == 2:
			if (ar[i][j] + ar[i + 1][j] + ar[i - 1][j] + ar[i][j - 1]) % 2 == 0:
				ar2.append(1)
			else:
				ar2.append(0)
		elif i == 2 and 0 < j < 2:
			if (ar[i][j] + ar[i][j + 1] + ar[i - 1][j] + ar[i][j - 1]) % 2 == 0:
				ar2.append(1)
			else:
				ar2.append(0)
		elif 0 < i < 2 and 0 < j < 2:
			if (ar[i][j] + ar[i + 1][j] + ar[i][j + 1] + ar[i - 1][j] + ar[i][j - 1]) % 2 == 0:
				ar2.append(1)
			else:
				ar2.append(0)
		elif i == 0 and j == 2:
			if (ar[i][j] + ar[i + 1][j] + ar[i][j - 1]) % 2 == 0:
				ar2.append(1)
			else:
				ar2.append(0)
		elif i == 2 and j == 0:
			if (ar[i][j] + ar[i][j + 1] + ar[i - 1][j]) % 2 == 0:
				ar2.append(1)
			else:
				ar2.append(0)
for i in range(0, 3):
	for j in range(0, 3):
		if j == 2:
			print(ar2[a], end='\n')
			a = a + 1
		elif j < 3:
			print(ar2[a], end='')
			a = a + 1


def suma(n, m):
	cont = 0
	cont += numbers[n][m]
	cont += numbers[n - 1][m]
	cont += numbers[n + 1][m]
	cont += numbers[n][m - 1]
	cont += numbers[n][m + 1]
	return cont
matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]
numbers = [[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 x in range(1, 4):
	s = input().split(' ')
	s = list(map(int, s))
	(numbers[x][1], numbers[x][2], numbers[x][3]) = s
for x in range(1, 4):
	for y in range(1, 4):
		nm = suma(x, y)
		if nm % 2 == 0:
			matrix[x][y] = 1
		else:
			matrix[x][y] = 0
for x in range(1, 4):
	print(f'{matrix[x][1]}{matrix[x][2]}{matrix[x][3]}')


a = []
l = []
for i in range(3):
	t = list(map(int, input().split()))
	t.append(0)
	l.append(t)
	a.append([1, 1, 1])
l.append([0, 0, 0, 0])
for i in range(3):
	for j in range(3):
		state = l[i][j] + l[i + 1][j] + l[i - 1][j] + l[i][j + 1] + l[i][j - 1]
		if state % 2 == 1:
			a[i][j] = 0
for k in range(3):
	print(str(a[k][0]) + str(a[k][1]) + str(a[k][2]))


(a1, a2, a3) = map(int, input().split())
(b1, b2, b3) = map(int, input().split())
(c1, c2, c3) = map(int, input().split())
r1 = [True, True, True]
r2 = [True, True, True]
r3 = [True, True, True]
if a1 % 2 != 0:
	r1[0] = not r1[0]
	r1[1] = not r1[1]
	r2[0] = not r2[0]
if a2 % 2 != 0:
	r1[1] = not r1[1]
	r1[0] = not r1[0]
	r1[2] = not r1[2]
	r2[1] = not r2[1]
if a3 % 2 != 0:
	r1[2] = not r1[2]
	r1[1] = not r1[1]
	r2[2] = not r2[2]
if b1 % 2 != 0:
	r2[0] = not r2[0]
	r1[0] = not r1[0]
	r2[1] = not r2[1]
	r3[0] = not r3[0]
if b2 % 2 != 0:
	r2[1] = not r2[1]
	r1[1] = not r1[1]
	r2[0] = not r2[0]
	r2[2] = not r2[2]
	r3[1] = not r3[1]
if b3 % 2 != 0:
	r2[2] = not r2[2]
	r1[2] = not r1[2]
	r2[1] = not r2[1]
	r3[2] = not r3[2]
if c1 % 2 != 0:
	r3[0] = not r3[0]
	r2[0] = not r2[0]
	r3[1] = not r3[1]
if c2 % 2 != 0:
	r3[1] = not r3[1]
	r3[0] = not r3[0]
	r2[1] = not r2[1]
	r3[2] = not r3[2]
if c3 % 2 != 0:
	r3[2] = not r3[2]
	r2[2] = not r2[2]
	r3[1] = not r3[1]
for i in range(0, 3):
	print(int(r1[i]), end='')
print()
for i in range(0, 3):
	print(int(r2[i]), end='')
print()
for i in range(0, 3):
	print(int(r3[i]), end='')
print()


(a11, a12, a13) = map(int, input().split())
(a21, a22, a23) = map(int, input().split())
(a31, a32, a33) = map(int, input().split())
(l1, l2, l3) = ('', '', '')
if (a11 + a12 + a21) % 2 == 0:
	l1 += '1'
else:
	l1 += '0'
if (a11 + a12 + a13 + a22) % 2 == 0:
	l1 += '1'
else:
	l1 += '0'
if (a12 + a13 + a23) % 2 == 0:
	l1 += '1'
else:
	l1 += '0'
if (a11 + a21 + a22 + a31) % 2 == 0:
	l2 += '1'
else:
	l2 += '0'
if (a12 + a21 + a22 + a23 + a32) % 2 == 0:
	l2 += '1'
else:
	l2 += '0'
if (a13 + a22 + a23 + a33) % 2 == 0:
	l2 += '1'
else:
	l2 += '0'
if (a21 + a31 + a32) % 2 == 0:
	l3 += '1'
else:
	l3 += '0'
if (a22 + a31 + a32 + a33) % 2 == 0:
	l3 += '1'
else:
	l3 += '0'
if (a23 + a32 + a33) % 2 == 0:
	l3 += '1'
else:
	l3 += '0'
print(l1)
print(l2)
print(l3)


ans = [1] * 9
l = []
for i in range(3):
	l.extend(list(map(int, input().split())))
for i in range(9):
	if l[i] & 1:
		if ans[i] == 1:
			ans[i] = 0
		else:
			ans[i] = 1
		if i % 3 == 0:
			if i > 2:
				if ans[i - 3] == 1:
					ans[i - 3] = 0
				else:
					ans[i - 3] = 1
			if i < 6:
				if ans[i + 3] == 1:
					ans[i + 3] = 0
				else:
					ans[i + 3] = 1
			if ans[i + 1] == 1:
				ans[i + 1] = 0
			else:
				ans[i + 1] = 1
		elif i % 3 == 1:
			if i > 2:
				if ans[i - 3] == 1:
					ans[i - 3] = 0
				else:
					ans[i - 3] = 1
			if i < 6:
				if ans[i + 3] == 1:
					ans[i + 3] = 0
				else:
					ans[i + 3] = 1
			if ans[i + 1] == 1:
				ans[i + 1] = 0
			else:
				ans[i + 1] = 1
			if ans[i - 1] == 1:
				ans[i - 1] = 0
			else:
				ans[i - 1] = 1
		else:
			if i > 2:
				if ans[i - 3] == 1:
					ans[i - 3] = 0
				else:
					ans[i - 3] = 1
			if i < 6:
				if ans[i + 3] == 1:
					ans[i + 3] = 0
				else:
					ans[i + 3] = 1
			if ans[i - 1] == 1:
				ans[i - 1] = 0
			else:
				ans[i - 1] = 1
print(''.join((str(i) for i in ans[:3])))
print(''.join((str(i) for i in ans[3:6])))
print(''.join((str(i) for i in ans[6:9])))


outgrid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]

def toggle(i, j):
	global outgrid
	if outgrid[i][j] == 0:
		outgrid[i][j] = 1
	else:
		outgrid[i][j] = 0

def sim(i, j, times):
	global outgrid
	for t in range(times):
		toggle(i, j)
		if i > 0:
			toggle(i - 1, j)
		if i < 2:
			toggle(i + 1, j)
		if j > 0:
			toggle(i, j - 1)
		if j < 2:
			toggle(i, j + 1)
grid = []
for i in range(3):
	grid.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		sim(i, j, grid[i][j])
for i in outgrid:
	temp = [str(x) for x in i]
	print(''.join(temp))


(a, b, c) = map(int, input().split())
(e, f, g) = map(int, input().split())
(h, i, j) = map(int, input().split())
row1Array = [a, b, c]
row2Array = [e, f, g]
row3Array = [h, i, j]
mainMetrix = [row1Array, row2Array, row3Array]
toggleMetrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for (i, row) in enumerate(mainMetrix):
	for (j, column) in enumerate(mainMetrix[i]):
		mainMetrix[i][j] = int(mainMetrix[i][j]) % 2
for (i, row) in enumerate(mainMetrix):
	for (j, column) in enumerate(mainMetrix[i]):
		if int(mainMetrix[i][j]) != 0:
			toggleMetrix[i][j] = 0 if toggleMetrix[i][j] else 1
			if j - 1 >= 0 and j - 1 < 3:
				toggleMetrix[i][j - 1] = 0 if toggleMetrix[i][j - 1] else 1
			if j + 1 >= 0 and j + 1 < 3:
				toggleMetrix[i][j + 1] = 0 if toggleMetrix[i][j + 1] else 1
			if i - 1 >= 0 and i - 1 < 3:
				toggleMetrix[i - 1][j] = 0 if toggleMetrix[i - 1][j] else 1
			if i + 1 >= 0 and i + 1 < 3:
				toggleMetrix[i + 1][j] = 0 if toggleMetrix[i + 1][j] else 1
for (i, row) in enumerate(toggleMetrix):
	result = ''
	for (j, column) in enumerate(toggleMetrix[i]):
		result += str(toggleMetrix[i][j])
	print(result)


tab = []
result = []
for i in range(0, 3):
	a = [int(i) for i in input().split()]
	tab.append(a)
	result.append([True, True, True])
if tab[0][0] % 2 != 0:
	result[0][0] = not result[0][0]
	result[1][0] = not result[1][0]
	result[0][1] = not result[0][1]
if tab[1][0] % 2 != 0:
	result[0][0] = not result[0][0]
	result[1][0] = not result[1][0]
	result[2][0] = not result[2][0]
	result[1][1] = not result[1][1]
if tab[2][0] % 2 != 0:
	result[2][0] = not result[2][0]
	result[2][1] = not result[2][1]
	result[1][0] = not result[1][0]
if tab[0][1] % 2 != 0:
	result[0][0] = not result[0][0]
	result[0][1] = not result[0][1]
	result[1][1] = not result[1][1]
	result[0][2] = not result[0][2]
if tab[1][1] % 2 != 0:
	result[1][1] = not result[1][1]
	result[0][1] = not result[0][1]
	result[2][1] = not result[2][1]
	result[1][0] = not result[1][0]
	result[1][2] = not result[1][2]
if tab[2][1] % 2 != 0:
	result[1][1] = not result[1][1]
	result[2][0] = not result[2][0]
	result[2][1] = not result[2][1]
	result[2][2] = not result[2][2]
if tab[0][2] % 2 != 0:
	result[0][1] = not result[0][1]
	result[0][2] = not result[0][2]
	result[1][2] = not result[1][2]
if tab[1][2] % 2 != 0:
	result[0][2] = not result[0][2]
	result[1][1] = not result[1][1]
	result[1][2] = not result[1][2]
	result[2][2] = not result[2][2]
if tab[2][2] % 2 != 0:
	result[2][2] = not result[2][2]
	result[2][1] = not result[2][1]
	result[1][2] = not result[1][2]
for i in range(0, 3):
	for j in range(0, 3):
		print(int(result[i][j]), end='')
	print()


g = [[0 for _ in range(3)] for _ in range(3)]
q = [list(map(lambda x: int(x) % 2, input().split(' '))) for _ in range(3)]
ds = [(0, 0), (-1, 0), (0, 1), (1, 0), (0, -1)]
for i in range(3):
	for j in range(3):
		if q[i][j] == 1:
			for (dx, dy) in ds:
				ni = i + dx
				nj = j + dy
				if ni >= 0 and ni < 3 and (nj >= 0) and (nj < 3):
					g[ni][nj] += 1
for row in g:
	for x in row:
		if x % 2 == 1:
			print(0, end='')
		else:
			print(1, end='')
	print()


a = [[True, True, True, True, True] for i in range(5)]
for i in range(1, 4):
	x = list(map(int, input().split()))
	for t in range(1, 4):
		if x[t - 1] % 2:
			a[i - 1][t] = not a[i - 1][t]
			a[i][t] = not a[i][t]
			a[i + 1][t] = not a[i + 1][t]
			a[i][t - 1] = not a[i][t - 1]
			a[i][t + 1] = not a[i][t + 1]
for i in range(1, 4):
	print(''.join(list(map(lambda x: str(int(x)), a[i]))[1:4]))


n = []
for i in range(0, 3):
	n.append([int(i) for i in input().split()])
a = []
for i in range(0, 3):
	b = []
	for j in range(0, 3):
		b.append(1)
	a.append(b)
for i in range(0, 3):
	for j in range(0, 3):
		if n[i][j] % 2 != 0:
			if a[i][j] == 0:
				a[i][j] = 1
			else:
				a[i][j] = 0
			if i - 1 >= 0:
				if a[i - 1][j] == 1:
					a[i - 1][j] = 0
				else:
					a[i - 1][j] = 1
			if i + 1 < 3:
				if a[i + 1][j] == 1:
					a[i + 1][j] = 0
				else:
					a[i + 1][j] = 1
			if j + 1 < 3:
				if a[i][j + 1] == 1:
					a[i][j + 1] = 0
				else:
					a[i][j + 1] = 1
			if j - 1 >= 0:
				if a[i][j - 1] == 1:
					a[i][j - 1] = 0
				else:
					a[i][j - 1] = 1
print(*a[0], sep='')
print(*a[1], sep='')
print(*a[2], sep='')


mat = [[1 for i in range(5)] for i in range(5)]
for i in range(1, 4):
	q = list(map(int, input().split()))
	for (j, x) in enumerate(q):
		e = x % 2
		if e == 1:
			if mat[i][j + 1] == 0:
				mat[i][j + 1] = 1
			else:
				mat[i][j + 1] = 0
			if mat[i][j] == 0:
				mat[i][j] = 1
			else:
				mat[i][j] = 0
			if mat[i][j + 2] == 0:
				mat[i][j + 2] = 1
			else:
				mat[i][j + 2] = 0
			if mat[i - 1][j + 1] == 0:
				mat[i - 1][j + 1] = 1
			else:
				mat[i - 1][j + 1] = 0
			if mat[i + 1][j + 1] == 0:
				mat[i + 1][j + 1] = 1
			else:
				mat[i + 1][j + 1] = 0
for i in range(1, 4):
	for j in range(1, 4):
		print(mat[i][j], end='')
	if i == 3:
		break
	print()


grid = [[1 for j in range(3)] for i in range(3)]
switches = []
for i in range(3):
	line = input()
	switches.append([int(i) for i in line.split(' ')])
for switch_row in range(3):
	for switch_col in range(3):
		if switches[switch_row][switch_col] % 2 == 0:
			continue
		grid[switch_row][switch_col] = int(not grid[switch_row][switch_col])
		if switch_row == 0:
			grid[switch_row + 1][switch_col] = int(not grid[switch_row + 1][switch_col])
		elif switch_row == 1:
			grid[switch_row + 1][switch_col] = int(not grid[switch_row + 1][switch_col])
			grid[switch_row - 1][switch_col] = int(not grid[switch_row - 1][switch_col])
		elif switch_row == 2:
			grid[switch_row - 1][switch_col] = int(not grid[switch_row - 1][switch_col])
		if switch_col == 0:
			grid[switch_row][switch_col + 1] = int(not grid[switch_row][switch_col + 1])
		elif switch_col == 1:
			grid[switch_row][switch_col + 1] = int(not grid[switch_row][switch_col + 1])
			grid[switch_row][switch_col - 1] = int(not grid[switch_row][switch_col - 1])
		elif switch_col == 2:
			grid[switch_row][switch_col - 1] = int(not grid[switch_row][switch_col - 1])
print('\n'.join([''.join(list(map(str, grid[i]))) for i in range(3)]))


import re

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())
m = []
for i in range(3):
	l = inlt()
	m.append(l)
for i in range(3):
	for j in range(3):
		s = 0
		if i - 1 >= 0:
			s += m[i - 1][j]
		if i + 1 < 3:
			s += m[i + 1][j]
		if j - 1 >= 0:
			s += m[i][j - 1]
		if j + 1 < 3:
			s += m[i][j + 1]
		s += m[i][j]
		if s % 2 == 0:
			print(1, end='')
		else:
			print(0, end='')
	print()


s = []
for i in range(3):
	s.append(list(map(int, input().split())))
g = []
for i in range(3):
	g.append([1, 1, 1])
ne = [(-1, 0), (0, -1), (0, 1), (1, 0)]

def toggle(n):
	if n == 1:
		return 0
	else:
		return 1
for i in range(3):
	for j in range(3):
		if s[i][j] % 2 == 0:
			continue
		else:
			g[i][j] = toggle(g[i][j])
			for k in ne:
				if (i + k[0] > -1 and i + k[0] < 3) and (j + k[1] > -1 and j + k[1] < 3):
					g[i + k[0]][j + k[1]] = toggle(g[i + k[0]][j + k[1]])
for i in g:
	for j in i:
		print(j, end='')
	print()


li = [[0 for j in range(3)] for i in range(3)]
li[0] = input().split(' ')
li[1] = input().split(' ')
li[2] = input().split(' ')
for i in range(3):
	for j in range(3):
		li[i][j] = int(li[i][j])
arr = [[0 for j in range(3)] for i in range(3)]
k = [[0 for j in range(3)] for i in range(3)]
for i in range(3):
	for j in range(3):
		if i == 0 and j == 0:
			arr[0][0] += li[0][0]
			arr[0][1] += li[0][0]
			arr[1][0] += li[0][0]
		elif i == 0 and j == 1:
			arr[0][1] += li[0][1]
			arr[0][0] += li[0][1]
			arr[0][2] += li[0][1]
			arr[1][1] += li[0][1]
		elif i == 0 and j == 2:
			arr[0][2] += li[0][2]
			arr[0][1] += li[0][2]
			arr[1][2] += li[0][2]
		elif i == 1 and j == 0:
			arr[1][0] += li[1][0]
			arr[0][0] += li[1][0]
			arr[1][1] += li[1][0]
			arr[2][0] += li[1][0]
		elif i == 1 and j == 1:
			arr[1][1] += li[1][1]
			arr[0][1] += li[1][1]
			arr[1][0] += li[1][1]
			arr[1][2] += li[1][1]
			arr[2][1] += li[1][1]
		elif i == 1 and j == 2:
			arr[1][2] += li[1][2]
			arr[0][2] += li[1][2]
			arr[1][1] += li[1][2]
			arr[2][2] += li[1][2]
		elif i == 2 and j == 0:
			arr[2][0] += li[2][0]
			arr[1][0] += li[2][0]
			arr[2][1] += li[2][0]
		elif i == 2 and j == 1:
			arr[2][1] += li[2][1]
			arr[1][1] += li[2][1]
			arr[2][0] += li[2][1]
			arr[2][2] += li[2][1]
		elif i == 2 and j == 2:
			arr[2][2] += li[2][2]
			arr[1][2] += li[2][2]
			arr[2][1] += li[2][2]
for i in range(3):
	for j in range(3):
		if arr[i][j] % 2 == 0:
			k[i][j] = 1
		else:
			k[i][j] == 0
print('{}{}{}'.format(k[0][0], k[0][1], k[0][2]))
print('{}{}{}'.format(k[1][0], k[1][1], k[1][2]))
print('{}{}{}'.format(k[2][0], k[2][1], k[2][2]))


a = [[int(i) for i in input().split()] for j in range(3)]
ans = [[1 for i in range(3)] for j in range(3)]
for i in range(3):
	for j in range(3):
		if a[i][j] % 2 != 0:
			for x in range(3):
				for y in range(3):
					if x == i and y == j + 1 or (x == i and y == j - 1) or (x == i + 1 and y == j) or (x == i - 1 and y == j) or (x == i and y == j):
						ans[x][y] ^= 1
for x in range(3):
	for y in range(3):
		print(ans[x][y], end='')
	print()


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


grid = [list(map(int, input().split())) for e in range(3)]
ans = [[1, 1, 1] for e in [1, 2, 3]]
ans[1] = [ans[1][k] + grid[0][k] + grid[1][k] + grid[2][k] for k in [0, 1, 2]]
ans[0] = [ans[0][k] + grid[0][k] + grid[1][k] for k in [0, 1, 2]]
ans[2] = [ans[2][k] + grid[2][k] + grid[1][k] for k in [0, 1, 2]]
for k in [0, 1, 2]:
	ans[k][0] += grid[k][1]
for k in [0, 1, 2]:
	ans[k][2] += grid[k][1]
for k in [0, 1, 2]:
	ans[k][1] += grid[k][0] + grid[k][2]
print('\n'.join([''.join([str(e % 2) for e in ans[k]]) for k in [0, 1, 2]]))


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])
print(''.join(is_on[0:3]) + '\n' + ''.join(is_on[3:6]) + '\n' + ''.join(is_on[6:9]))


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


arr = []
for i in range(3):
	arr.append(list(map(int, input().split())))
sides = [[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1]]
light = [[1 for _ in range(3)] for _ in range(3)]
for i in range(3):
	for j in range(3):
		sum = 0
		for s in sides:
			if 0 <= i + s[0] < 3 and 0 <= j + s[1] < 3:
				sum += arr[i + s[0]][j + s[1]]
		if sum % 2 != 0:
			light[i][j] = 0
for i in range(3):
	for j in range(3):
		print(light[i][j], end='')
	print()


def Side_Adjacent(i, j):
	A = [[i - 1, j], [i + 1, j], [i, j - 1], [i, j + 1], [i, j]]
	return A
Lights = [[True for i in range(3)] for j in range(3)]
for i in range(3):
	X = list(map(int, input().split()))
	for j in range(3):
		if X[j] % 2 != 0:
			for A in Side_Adjacent(i, j):
				if -1 not in A and 3 not in A:
					Lights[A[0]][A[1]] = not Lights[A[0]][A[1]]
for i in range(3):
	print(*[0 if L == False else 1 for L in Lights[i]], sep='')


light = []
n = []
for i in range(3):
	n.append(input().split())
	light.append([1, 1, 1])
i = 0
c = 0
for m in n:
	for s in m:
		s = int(s)
		while s > 0:
			for j in range(i - 1, i + 2):
				if j >= 0 and j < 3:
					if light[j][c] == 0:
						light[j][c] = 1
					else:
						light[j][c] = 0
			for j in range(c - 1, c + 2):
				if j >= 0 and j < 3 and (j != c):
					if light[i][j] == 0:
						light[i][j] = 1
					else:
						light[i][j] = 0
			s -= 1
		if c < 2:
			c += 1
		else:
			c = 0
			i += 1
lit = ''
sup = 0
for row in light:
	for num in row:
		lit += str(num)
	if sup < 2:
		lit += '\n'
		sup += 1
print(lit)


def toggle(a, i, j, ans):
	r = [-1, 0, 1, 0]
	c = [0, -1, 0, 1]
	for k in range(4):
		if i + r[k] >= 0 and i + r[k] < 3 and (j + c[k] < 3) and (j + c[k] >= 0):
			if ans[i + r[k]][j + c[k]] == 1:
				ans[i + r[k]][j + c[k]] = 0
			else:
				ans[i + r[k]][j + c[k]] = 1
a = []
for i in range(3):
	b = list(map(int, input().split()))
	a.append(b)
ans = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	for j in range(3):
		if a[i][j] % 2 == 1:
			ans[i][j] = 1 - ans[i][j]
			toggle(a, i, j, ans)
for i in range(3):
	for j in range(3):
		print(ans[i][j], end='')
	print()


class LightOut:

	def __init__(self, input_square):
		self.square = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
		self.input_square = input_square
		self._isOdd_()

	def _isOdd_(self):
		for i in range(3):
			for j in range(3):
				self.input_square[i][j] = int(self.input_square[i][j] % 2)

	def translate(self):
		for i in range(3):
			for j in range(3):
				n = self.input_square[i][j]
				if n == 1:
					(ix, jx) = (None, None)
					self.square[i][j] = 0 if self.square[i][j] == 1 else 1
					if i < 2:
						self.square[i + 1][j] = 0 if self.square[i + 1][j] == 1 else 1
					if i > 0:
						self.square[i - 1][j] = 0 if self.square[i - 1][j] == 1 else 1
					if j < 2:
						self.square[i][j + 1] = 0 if self.square[i][j + 1] == 1 else 1
					if j > 0:
						self.square[i][j - 1] = 0 if self.square[i][j - 1] == 1 else 1

	def print(self):
		for i in range(3):
			for j in range(2):
				print(self.square[i][j], end='')
			print(self.square[i][j + 1])
l = [list(map(int, input().split(' '))) for _ in range(3)]
lo = LightOut(input_square=l)
lo.translate()
lo.print()


ans = [[1] * 3 for _ in range(3)]
for i in range(3):
	a = [int(i) for i in input().split()]
	for j in range(3):
		if a[j] % 2:
			ans[i][j] = 1 - ans[i][j]
			if j > 0:
				ans[i][j - 1] = 1 - ans[i][j - 1]
			if j < 2:
				ans[i][j + 1] = 1 - ans[i][j + 1]
			if i > 0:
				ans[i - 1][j] = 1 - ans[i - 1][j]
			if i < 2:
				ans[i + 1][j] = 1 - ans[i + 1][j]
for row in ans:
	for elem in row:
		print(elem, end='')
	print()


ours = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]

def isEven(n):
	if n % 2 == 0:
		return True
	else:
		return False

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

def corrosp(m):
	if m == '00':
		ours[0][1] = toggle(ours[0][1])
		ours[1][0] = toggle(ours[1][0])
	if m == '01':
		ours[0][2] = toggle(ours[0][2])
		ours[0][0] = toggle(ours[0][0])
		ours[1][1] = toggle(ours[1][1])
	if m == '02':
		ours[0][1] = toggle(ours[0][1])
		ours[1][2] = toggle(ours[1][2])
	if m == '10':
		ours[1][1] = toggle(ours[1][1])
		ours[2][0] = toggle(ours[2][0])
		ours[0][0] = toggle(ours[0][0])
	if m == '11':
		ours[1][0] = toggle(ours[1][0])
		ours[0][1] = toggle(ours[0][1])
		ours[1][2] = toggle(ours[1][2])
		ours[2][1] = toggle(ours[2][1])
	if m == '12':
		ours[0][2] = toggle(ours[0][2])
		ours[1][1] = toggle(ours[1][1])
		ours[2][2] = toggle(ours[2][2])
	if m == '20':
		ours[1][0] = toggle(ours[1][0])
		ours[2][1] = toggle(ours[2][1])
	if m == '21':
		ours[2][0] = toggle(ours[2][0])
		ours[1][1] = toggle(ours[1][1])
		ours[2][2] = toggle(ours[2][2])
	if m == '22':
		ours[1][2] = toggle(ours[1][2])
		ours[2][1] = toggle(ours[2][1])
	return
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = list(map(int, input().split()))
arr = [x, y, z]
for i in range(3):
	for j in range(3):
		if isEven(arr[i][j]):
			pass
		else:
			ours[i][j] = toggle(ours[i][j])
			corrosp(str(i) + str(j))
for i in range(3):
	for j in range(3):
		print(ours[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()


i = 0
j = 0
q = []
for k in range(3):
	q.append([])
	for l in range(3):
		q[k].append(0)
while True:
	try:
		t = input().split(' ')
		for j in range(3):
			r = int(t[j])
			q[i][j] += r
			if i - 1 > -1:
				q[i - 1][j] += r
			if i + 1 < 3:
				q[i + 1][j] += r
			if j - 1 > -1:
				q[i][j - 1] += r
			if j + 1 < 3:
				q[i][j + 1] += r
		i += 1
	except EOFError:
		break
for i in range(3):
	for j in range(3):
		r = '1' if q[i][j] % 2 == 0 else '0'
		print(r, end='')
	print('\n', end='')


a = []
ans = []
for i in range(3):
	a.append([int(a) for a in input().split()])
	ans.append([0, 0, 0, 0, 0])
ans.append([0, 0, 0, 0, 0])
ans.append([0, 0, 0, 0, 0])
for i in range(3):
	for j in range(3):
		if a[i][j] % 2 == 1:
			ans[i + 1][j + 1] += 1
			ans[i + 1][j + 2] += 1
			ans[i + 1][j] += 1
			ans[i + 2][j + 1] += 1
			ans[i][j + 1] += 1
for i in range(1, 4):
	for j in range(1, 4):
		if ans[i][j] % 2 == 0:
			print(1, end='')
		else:
			print(0, end='')
	print()


b1 = input().split(' ')
b2 = input().split(' ')
b3 = input().split(' ')
a1 = [int(i) for i in b1]
a2 = [int(i) for i in b2]
a3 = [int(i) for i in b3]
a = list()
a.append(a1)
a.append(a2)
a.append(a3)
y = [['1', '1', '1'], ['1', '1', '1'], ['1', '1', '1']]
if (a[0][0] + a[1][0] + a[0][1]) % 2 != 0:
	y[0][0] = '0'
if (a[0][0] + a[0][2] + a[0][1] + a[1][1]) % 2 != 0:
	y[0][1] = '0'
if (a[1][2] + a[0][2] + a[0][1]) % 2 != 0:
	y[0][2] = '0'
if (a[0][0] + a[1][0] + a[2][0] + a[1][1]) % 2 != 0:
	y[1][0] = '0'
if (a[0][1] + a[1][0] + a[1][1] + a[1][2] + a[2][1]) % 2 != 0:
	y[1][1] = '0'
if (a[1][2] + a[0][2] + a[2][2] + a[1][1]) % 2 != 0:
	y[1][2] = '0'
if (a[1][0] + a[2][0] + a[2][1]) % 2 != 0:
	y[2][0] = '0'
if (a[2][0] + a[2][2] + a[2][1] + a[1][1]) % 2 != 0:
	y[2][1] = '0'
if (a[2][1] + a[2][2] + a[1][2]) % 2 != 0:
	y[2][2] = '0'
for i in range(0, 3):
	print(y[i][0] + y[i][1] + y[i][2])


grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
presses = []
for i in range(3):
	presses.append([int(x) for x in input().split()])
for x in range(3):
	for y in range(3):
		foo = presses[x][y]
		for i in range(foo):
			grid[x][y] = int(not grid[x][y])
			if x != 0:
				grid[x - 1][y] = int(not grid[x - 1][y])
			if x != 2:
				grid[x + 1][y] = int(not grid[x + 1][y])
			if y != 0:
				grid[x][y - 1] = int(not grid[x][y - 1])
			if y != 2:
				grid[x][y + 1] = int(not grid[x][y + 1])
for line in grid:
	print(''.join([str(x) for x in line]))


def toggle(item):
	if item == 0:
		item = 1
	elif item == 1:
		item = 0
	return item
clicked = []
board = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	clicked.append(list(map(int, input().split())))
row = 0
col = 0
while row < 3:
	while col < 3:
		for i in range(clicked[row][col]):
			board[row][col] = toggle(board[row][col])
			if row > 0:
				board[row - 1][col] = toggle(board[row - 1][col])
			if row < 2:
				board[row + 1][col] = toggle(board[row + 1][col])
			if col > 0:
				board[row][col - 1] = toggle(board[row][col - 1])
			if col < 2:
				board[row][col + 1] = toggle(board[row][col + 1])
		col += 1
	col = 0
	row += 1
for row in board:
	for col in row:
		print(col, end='')
	print()


res = [[0 for _ in range(3)] for i in range(3)]
for i in range(3):
	a = input().split(' ')
	for j in range(3):
		res[i][j] = a[j]
f = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
if int(res[0][0]) % 2 != 0:
	f[0][0] = 0 if f[0][0] == 1 else 1
	f[0][1] = 0 if f[0][1] == 1 else 1
	f[1][0] = 0 if f[1][0] == 1 else 1
if int(res[0][1]) % 2 != 0:
	f[0][1] = 0 if f[0][1] == 1 else 1
	f[0][0] = 0 if f[0][0] == 1 else 1
	f[0][2] = 0 if f[0][2] == 1 else 1
	f[1][1] = 0 if f[1][1] == 1 else 1
if int(res[0][2]) % 2 != 0:
	f[0][2] = 0 if f[0][2] == 1 else 1
	f[1][2] = 0 if f[1][2] == 1 else 1
	f[0][1] = 0 if f[0][1] == 1 else 1
if int(res[1][0]) % 2 != 0:
	f[1][0] = 0 if f[1][0] == 1 else 1
	f[2][0] = 0 if f[2][0] == 1 else 1
	f[0][0] = 0 if f[0][0] == 1 else 1
	f[1][1] = 0 if f[1][1] == 1 else 1
if int(res[1][1]) % 2 != 0:
	f[1][2] = 0 if f[1][2] == 1 else 1
	f[1][0] = 0 if f[1][0] == 1 else 1
	f[2][1] = 0 if f[2][1] == 1 else 1
	f[0][1] = 0 if f[0][1] == 1 else 1
	f[1][1] = 0 if f[1][1] == 1 else 1
if int(res[1][2]) % 2 != 0:
	f[1][1] = 0 if f[1][1] == 1 else 1
	f[2][2] = 0 if f[2][2] == 1 else 1
	f[0][2] = 0 if f[0][2] == 1 else 1
	f[1][2] = 0 if f[1][2] == 1 else 1
if int(res[2][0]) % 2 != 0:
	f[1][0] = 0 if f[1][0] == 1 else 1
	f[2][0] = 0 if f[2][0] == 1 else 1
	f[2][1] = 0 if f[2][1] == 1 else 1
if int(res[2][1]) % 2 != 0:
	f[2][0] = 0 if f[2][0] == 1 else 1
	f[2][1] = 0 if f[2][1] == 1 else 1
	f[2][2] = 0 if f[2][2] == 1 else 1
	f[1][1] = 0 if f[1][1] == 1 else 1
if int(res[2][2]) % 2 != 0:
	f[1][2] = 0 if f[1][2] == 1 else 1
	f[2][2] = 0 if f[2][2] == 1 else 1
	f[2][1] = 0 if f[2][1] == 1 else 1
for i in f:
	for j in i:
		print(j, end='')
	print()


fr = [int(i) for i in input().split(' ')]
sr = [int(i) for i in input().split(' ')]
tr = [int(i) for i in input().split(' ')]
grid = [[1, 1, 1] for _ in range(3)]
p_grid = [fr, sr, tr]

def coord(x, y):
	c1 = (x + 1, y) if x + 1 < 3 else None
	c2 = (x - 1, y) if x - 1 >= 0 else None
	c3 = (x, y + 1) if y + 1 < 3 else None
	c4 = (x, y - 1) if y - 1 >= 0 else None
	c5 = (x, y)
	coords = [c1, c2, c3, c4, c5]
	return [c for c in coords if c is not None]
for x in range(3):
	for y in range(3):
		if p_grid[x][y] % 2 == 0:
			continue
		else:
			for c in coord(x, y):
				if grid[c[0]][c[1]] == 1:
					grid[c[0]][c[1]] = 0
				else:
					grid[c[0]][c[1]] = 1
for row in grid:
	print(''.join((str(c) for c in row)))


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):
		sum = 0
		if i > 0:
			sum += a[i - 1][j]
		if i < 2:
			sum += a[i + 1][j]
		if j > 0:
			sum += a[i][j - 1]
		if j < 2:
			sum += a[i][j + 1]
		b[i][j] = sum + 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('')


luces = []
resultado = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	fila = list(str(input()).split())
	for j in range(len(fila)):
		fila[j] = int(fila[j])
	luces.append(fila)
for i in range(len(luces)):
	for j in range(len(luces[i])):
		if luces[i][j] % 2 != 0:
			if resultado[i][j] == 0:
				resultado[i][j] = 1
			else:
				resultado[i][j] = 0
			if j + 1 >= 0 and j + 1 <= 2:
				if resultado[i][j + 1] == 0:
					resultado[i][j + 1] = 1
				else:
					resultado[i][j + 1] = 0
			if j - 1 >= 0:
				if resultado[i][j - 1] == 0:
					resultado[i][j - 1] = 1
				else:
					resultado[i][j - 1] = 0
			if i + 1 >= 0 and i + 1 <= 2:
				if resultado[i + 1][j] == 0:
					resultado[i + 1][j] = 1
				else:
					resultado[i + 1][j] = 0
			if i - 1 >= 0:
				if resultado[i - 1][j] == 0:
					resultado[i - 1][j] = 1
				else:
					resultado[i - 1][j] = 0
for i in range(3):
	print(str(resultado[i][0]) + str(resultado[i][1]) + str(resultado[i][2]))


def neighbours_sum(matr, i, j):
	return sum([matr[i - 1][j], matr[i][j - 1], matr[i + 1][j], matr[i][j + 1]])
matr = []
matr.append([0] * 5)
for _ in range(3):
	matr.append([0] + list(map(int, input().strip().split(' '))) + [0])
matr.append([0] * 5)
toggles = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
	for j in range(3):
		toggles[i][j] = neighbours_sum(matr, i + 1, j + 1) + matr[i + 1][j + 1]
		if toggles[i][j] % 2 == 1:
			toggles[i][j] = 0
		else:
			toggles[i][j] = 1
for row in toggles:
	print(''.join(list(map(str, row))))


grid = [[1] * 3 for _ in range(3)]
nums = [[0] * 3 for _ in range(3)]
for i in range(3):
	nums[i] = list(map(int, input().split()))
for j in range(3):
	for k in range(3):
		if nums[j][k] > 0 and nums[j][k] % 2 != 0:
			grid[j][k] ^= 1
			if j == 0:
				if k == 0:
					grid[j + 1][k] ^= 1
					grid[j][k + 1] ^= 1
				elif k == 2:
					grid[j][k - 1] ^= 1
					grid[j + 1][k] ^= 1
				else:
					grid[j + 1][k] ^= 1
					grid[j][k - 1] ^= 1
					grid[j][k + 1] ^= 1
			if j == 1:
				if k == 0:
					grid[j + 1][k] ^= 1
					grid[j - 1][k] ^= 1
					grid[j][k + 1] ^= 1
				elif k == 1:
					grid[j][k + 1] ^= 1
					grid[j][k - 1] ^= 1
					grid[j + 1][k] ^= 1
					grid[j - 1][k] ^= 1
				else:
					grid[j + 1][k] ^= 1
					grid[j - 1][k] ^= 1
					grid[j][k - 1] ^= 1
			if j == 2:
				if k == 0:
					grid[j][k + 1] ^= 1
					grid[j - 1][k] ^= 1
				elif k == 1:
					grid[j][k - 1] ^= 1
					grid[j][k + 1] ^= 1
					grid[j - 1][k] ^= 1
				else:
					grid[j][k - 1] ^= 1
					grid[j - 1][k] ^= 1
for t in range(3):
	for j in range(3):
		print(grid[t][j], end='')
	print(' ')


lights = [[1 for _ in range(5)] for j in range(5)]
presses = [[0 for _ in range(5)] for j in range(5)]
for i in range(1, 4):
	for (j, k) in zip(range(1, 4), input().split()):
		presses[i][j] = int(k)
for i in range(1, 4):
	for j in range(1, 4):
		if presses[i][j] & 1:
			lights[i - 1][j] = 0 if lights[i - 1][j] else 1
			lights[i][j - 1] = 0 if lights[i][j - 1] else 1
			lights[i][j] = 0 if lights[i][j] else 1
			lights[i][j + 1] = 0 if lights[i][j + 1] else 1
			lights[i + 1][j] = 0 if lights[i + 1][j] else 1
for i in range(1, 4):
	print(lights[i][1], lights[i][2], lights[i][3], sep='')


l = [[0] * 5 for i in range(5)]
temp = []
for i in range(1, 4):
	(l[i][1], l[i][2], l[i][3]) = map(int, input().split())
for i in range(1, 4):
	ans = ''
	for j in range(1, 4):
		ans += '10'[(l[i][j] + l[i + 1][j] + l[i - 1][j] + l[i][j + 1] + l[i][j - 1]) % 2]
	temp.append(ans)
for i in range(3):
	print(temp[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())
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 = []
result = [[1 for i in range(3)] for i in range(3)]
for i in range(3):
	temp = [int(x) for x in input().split()]
	l.append(temp)
for i in range(3):
	for j in range(3):
		temp = 0
		for x in range(i - 1, i + 2):
			for y in range(j - 1, j + 2):
				if x >= 0 and x <= 2 and (y >= 0) and (y <= 2) and (abs(x - i) != abs(y - j)):
					temp += l[x][y] % 2
		temp += l[i][j] % 2
		result[i][j] -= temp % 2
for x in result:
	print(''.join([str(i) for i in x]))


res = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	ligne = list(map(int, input().split()))
	for j in range(3):
		if ligne[j] % 2 == 0:
			continue
		if i > 0:
			res[i - 1][j] = (1 + res[i - 1][j]) % 2
		if i < 2:
			res[i + 1][j] = (1 + res[i + 1][j]) % 2
		if j > 0:
			res[i][j - 1] = (1 + res[i][j - 1]) % 2
		if j < 2:
			res[i][j + 1] = (1 + res[i][j + 1]) % 2
		res[i][j] = (1 + res[i][j]) % 2
for e in res:
	print(''.join(map(str, e)))


def lightChanger(i, j):
	output[i][j] = output[i][j] ^ 1
	direction = [[0, 1], [1, 0], [0, -1], [-1, 0]]
	for (xDir, yDir) in direction:
		x = xDir + i
		y = yDir + j
		if 0 <= x < 3 and 0 <= y < 3:
			output[x][y] = output[x][y] ^ 1
matrix = []
output = [[1 for i in range(3)] for j in range(3)]
for _ in range(3):
	matrix.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		if matrix[i][j] % 2 == 1:
			lightChanger(i, j)
for x in output:
	for i in x:
		print(i, end='')
	print()


from functools import reduce
from collections import Counter
import time
import datetime

def time_t():
	print('Current date and time: ', datetime.datetime.now())
	print('Current year: ', datetime.date.today().strftime('%Y'))
	print('Month of year: ', datetime.date.today().strftime('%B'))
	print('Week number of the year: ', datetime.date.today().strftime('%W'))
	print('Weekday of the week: ', datetime.date.today().strftime('%w'))
	print('Day of year: ', datetime.date.today().strftime('%j'))
	print('Day of the month : ', datetime.date.today().strftime('%d'))
	print('Day of week: ', datetime.date.today().strftime('%A'))

def ip():
	return int(input())

def sip():
	return input()

def mip():
	return map(int, input().split())

def mips():
	return map(str, input().split())

def lip():
	return list(map(int, input().split()))

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst

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

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)
arr = [[0, 0, 0]]
for i in range(3):
	arr.append(lip())
arr.append([0, 0, 0])
for item in arr:
	item.append(0)
	item.insert(0, 0)
for i in range(1, 4):
	for j in range(1, 4):
		ans = arr[i][j] + arr[i - 1][j] + arr[i + 1][j] + arr[i][j + 1] + arr[i][j - 1] + 1
		if ans % 2 == 0:
			print(0, end='')
		else:
			print(1, end='')
	print()


data = [list(map(int, input().split())) for _ in range(3)]
result = [[1] * 3 for _ in range(3)]
d = [[0, 0], [1, 0], [-1, 0], [0, 1], [0, -1]]
for i in range(3):
	for j in range(3):
		if data[i][j] % 2 == 1:
			for n in d:
				if i + n[0] != -1 and j + n[1] != -1 and (i + n[0] != 3) and (j + n[1] != 3):
					result[i + n[0]][j + n[1]] ^= 1
for i in result:
	for j in i:
		print(j, end='')
	print()


def main():
	arr = []
	global narr
	narr = [[1 for i in range(3)] for j in range(3)]
	for _ in range(3):
		o = [int(x) % 2 for x in input().split()]
		arr.append(o)
	for i in range(3):
		for j in range(3):
			for times in range(arr[i][j]):
				narr[i][j] = (narr[i][j] + 1) % 2
				if i + 1 < 3:
					narr[i + 1][j] = (narr[i + 1][j] + 1) % 2
				if i - 1 >= 0:
					narr[i - 1][j] = (narr[i - 1][j] + 1) % 2
				if j - 1 >= 0:
					narr[i][j - 1] = (narr[i][j - 1] + 1) % 2
				if j + 1 < 3:
					narr[i][j + 1] = (narr[i][j + 1] + 1) % 2
	for i in narr:
		for j in i:
			print(j, end='')
		print()
main()


def isGood(x, y):
	if x >= 0 and x < 3 and (y >= 0) and (y < 3):
		return True
	return False
lg = [[0, 0, 0] for _ in range(3)]
g = [[1, 1, 1] for _ in range(3)]
for i in range(3):
	l = input().split()
	for (ii, li) in enumerate(l):
		lg[i][ii] = int(li) % 2
for (i, row) in enumerate(lg):
	for (j, cell) in enumerate(row):
		if lg[i][j] == 1:
			g[i][j] = 1 - g[i][j]
			if isGood(i - 1, j):
				g[i - 1][j] = 1 - g[i - 1][j]
			if isGood(i, j - 1):
				g[i][j - 1] = 1 - g[i][j - 1]
			if isGood(i + 1, j):
				g[i + 1][j] = 1 - g[i + 1][j]
			if isGood(i, j + 1):
				g[i][j + 1] = 1 - g[i][j + 1]
for row in g:
	print(''.join(list(map(lambda x: str(x), row))))


import sys
my_file = sys.stdin
map = [list(map(int, line.split())) for line in my_file.read().split('\n')]
original = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]

def printlst(lst):
	for line in lst:
		for i in line:
			print(i, end='')
		print()
for line in range(3):
	for row in range(3):
		if map[line][row] % 2 == 0:
			map[line][row] = 0
		else:
			map[line][row] = 1
for line in range(3):
	for row in range(3):
		if map[line][row] == 1:
			original[line][row] = original[line][row] ^ 1
			if line == 0:
				original[line + 1][row] = original[line + 1][row] ^ 1
			elif line == 2:
				original[line - 1][row] = original[line - 1][row] ^ 1
			else:
				original[line + 1][row] = original[line + 1][row] ^ 1
				original[line - 1][row] = original[line - 1][row] ^ 1
			if row == 0:
				original[line][row + 1] = original[line][row + 1] ^ 1
			elif row == 2:
				original[line][row - 1] = original[line][row - 1] ^ 1
			else:
				original[line][row + 1] = original[line][row + 1] ^ 1
				original[line][row - 1] = original[line][row - 1] ^ 1
printlst(original)


l = []

def add(i, j):
	res = l[i][j]
	m = [[i, j - 1], [i - 1, j], [i, j + 1], [i + 1, j]]
	for k in m:
		if 0 <= k[0] < 3 and 0 <= k[1] < 3:
			res += l[k[0]][k[1]]
	return res
for _ in range(3):
	m = list(map(int, input().split()))
	l.append(m)
for i in range(3):
	for j in range(3):
		if add(i, j) % 2 != 0:
			print(0, end='')
		else:
			print(1, end='')
	print('')


ans = 9 * [1]
abc = []
for i in range(3):
	x = list(map(int, input().split()))
	for j in range(3):
		abc.append(x[j])
a = [[1, 2, 4], [2, 1, 3, 5], [3, 2, 6], [4, 1, 5, 7], [5, 2, 4, 6, 8], [6, 3, 5, 9], [7, 4, 8], [8, 7, 5, 9], [9, 8, 6]]
for k in range(9):
	if abc[k] % 2 != 0:
		for p in range(len(a[k])):
			ans[a[k][p] - 1] = (ans[a[k][p] - 1] + 1) % 2
z = 0
for _ in range(3):
	for l in range(3):
		print(ans[z], end='')
		z += 1
	print()


from math import ceil, sqrt, gcd, log, floor
from collections import deque

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())

def msi():
	return map(str, input().strip().split(' '))

def lsi():
	return list(msi())
x = []
for i in range(3):
	x.append(li())
for i in range(3):
	for j in range(3):
		s = x[i][j]
		if i > 0:
			s += x[i - 1][j]
		if j > 0:
			s += x[i][j - 1]
		if i < 2:
			s += x[i + 1][j]
		if j < 2:
			s += x[i][j + 1]
		if s % 2 == 0:
			print('1', end='')
		else:
			print('0', end='')
	print()


l = []
for i in range(3):
	x = input().split()
	c = []
	for j in range(3):
		c.append(int(x[j]))
	l.append(c)
m = [['1', '1', '1'], ['1', '1', '1'], ['1', '1', '1']]

def toggle(n):
	if n == '0':
		return '1'
	else:
		return '0'
for i in range(3):
	for j in range(3):
		if l[i][j] % 2 != 0:
			m[i][j] = toggle(m[i][j])
			if i < 2:
				m[i + 1][j] = toggle(m[i + 1][j])
			if i > 0:
				m[i - 1][j] = toggle(m[i - 1][j])
			if j < 2:
				m[i][j + 1] = toggle(m[i][j + 1])
			if j > 0:
				m[i][j - 1] = toggle(m[i][j - 1])
for i in range(3):
	ans = ''.join(m[i])
	print(ans)


g = []
for i in range(3):
	g.append(list(map(int, input().split(' '))))
for i in range(3):
	for j in range(3):
		g[i][j] %= 2
c = [[1 for i in range(3)] for j in range(3)]
for i in range(3):
	for j in range(3):
		if not g[i][j]:
			continue
		c[i][j] += g[i][j]
		for dx in range(-1, 2):
			for dy in range(-1, 2):
				if dx != 0 and dy == 0 or (dx == 0 and dy != 0):
					x = dx + i
					y = dy + j
					if 0 <= x and x < 3 and (0 <= y) and (y < 3):
						c[x][y] += g[i][j]
for i in range(3):
	for j in range(3):
		c[i][j] = str(c[i][j] % 2)
for i in range(3):
	print(''.join(c[i]))


lights = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
ips = []
for i in range(0, 3):
	m = input()
	ips.append(m.split())
for i in range(0, 3):
	for j in range(0, 3):
		if int(ips[i][j]) % 2 == 1:
			lights[i][j] = 1 - lights[i][j]
			if i - 1 != -1:
				lights[i - 1][j] = 1 - lights[i - 1][j]
			if j - 1 != -1:
				lights[i][j - 1] = 1 - lights[i][j - 1]
			if i + 1 < 3:
				lights[i + 1][j] = 1 - lights[i + 1][j]
			if j + 1 < 3:
				lights[i][j + 1] = 1 - lights[i][j + 1]
for i in range(0, 3):
	for j in range(0, 3):
		lights[i][j] = str(lights[i][j])
	str1 = ''.join(lights[i])
	print(str1)


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

def arr_2d(n, m):
	return [[1 for x in range(m)] for i in range(n)]

def print_arr(arr):
	print(*arr, sep='')
matrix = arr_2d(3, 3)
for i in range(3):
	x = arr_inp()
	for j in range(3):
		if x[j] % 2:
			if j > 0:
				matrix[i][j - 1] = 1 - matrix[i][j - 1]
			if j < 2:
				matrix[i][j + 1] = 1 - matrix[i][j + 1]
			if i > 0:
				matrix[i - 1][j] = 1 - matrix[i - 1][j]
			if i < 2:
				matrix[i + 1][j] = 1 - matrix[i + 1][j]
			matrix[i][j] = 1 - matrix[i][j]
for i in range(3):
	print_arr(matrix[i])


n = []
for i in range(4 - 1):
	n.append(input().split())
a = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	for j in range(3):
		if int(n[i][j]) & 1:
			if i - 1 >= 0:
				a[i - 1][j] ^= 1 ^ 0
			if j - 1 >= 0:
				a[i][j - 1] ^= 1 ^ 0
			a[i][j] ^= 1 ^ 0
			if i + 1 < 3:
				a[i + 1][j] ^= 1 ^ 0
			if j + 1 < 3:
				a[i][j + 1] ^= 1 ^ 0
for i in a:
	print(*i, sep='')


import sys
import decimal
import collections
import math
import itertools as it

def readArray(type=int):
	line = input()
	return [type(x) for x in line.split()]

def cellIsValid(x, y):
	return 3 > x > -1 and 3 > y > -1

def invert(x):
	return (x + 1) % 2

def toggleCells(grid, r, c, n):
	if n % 2 == 0 or n == 0:
		return
	dx = [0, 0, 1, -1, 0]
	dy = [0, 1, 0, 0, -1]
	for (x, y) in zip(dx, dy):
		nr = r + x
		nc = c + y
		if cellIsValid(nr, nc):
			grid[nr][nc] = invert(grid[nr][nc])

def solve():
	grid = [[1] * 3 for _ in range(3)]
	press_count = []
	for x in range(3):
		press_count.append(readArray())
	for (r, row) in enumerate(press_count):
		for (c, x) in enumerate(row):
			toggleCells(grid, r, c, x)
	for row in grid:
		print(''.join([str(x) for x in row]))
solve()


arr = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
toggle = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(0, 3):
	var = [int(x) % 2 for x in input().split()]
	toggle[i] = var
for i in range(0, 3):
	for j in range(0, 3):
		if toggle[i][j] == 1:
			arr[i][j] = (arr[i][j] + 1) % 2
		if i >= 1 and toggle[i][j] == 1:
			arr[i - 1][j] = (arr[i - 1][j] + 1) % 2
		if j >= 1 and toggle[i][j] == 1:
			arr[i][j - 1] = (arr[i][j - 1] + 1) % 2
		if i <= 1 and toggle[i][j] == 1:
			arr[i + 1][j] = (arr[i + 1][j] + 1) % 2
		if j <= 1 and toggle[i][j] == 1:
			arr[i][j + 1] = (arr[i][j + 1] + 1) % 2
for i in range(0, 3):
	for j in range(0, 3):
		print(arr[i][j], end='')
	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
ind = 0
for i in m:
	for j in range(len(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
	ind += 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)


board = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]

def adj(i, j):
	res = []
	if i > 0:
		res.append((i - 1, j))
	if i < 2:
		res.append((i + 1, j))
	if j > 0:
		res.append((i, j - 1))
	if j < 2:
		res.append((i, j + 1))
	return res

def toggle(x):
	return 1 - x

def press(board, i, j, n):
	if n % 2 == 0:
		return
	board[i][j] = toggle(board[i][j])
	for (p, q) in adj(i, j):
		board[p][q] = toggle(board[p][q])
for i in range(3):
	row = [int(r) for r in input().split()]
	for j in range(3):
		press(board, i, j, row[j])
for row in board:
	print(''.join((str(x) for x in row)))


arr_entrada = []
for i in range(0, 3):
	arr_entrada.append(input())
rounds = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
results = [[True, True, True], [True, True, True], [True, True, True]]
for i in range(0, 3):
	for j in range(0, 3):
		rounds[i][j] = int(arr_entrada[i].split()[j])
if rounds[0][0] % 2 != 0:
	results[0][0] = not results[0][0]
	results[1][0] = not results[1][0]
	results[0][1] = not results[0][1]
if rounds[1][0] % 2 != 0:
	results[0][0] = not results[0][0]
	results[1][0] = not results[1][0]
	results[2][0] = not results[2][0]
	results[1][1] = not results[1][1]
if rounds[2][0] % 2 != 0:
	results[2][0] = not results[2][0]
	results[2][1] = not results[2][1]
	results[1][0] = not results[1][0]
if rounds[0][1] % 2 != 0:
	results[0][0] = not results[0][0]
	results[0][1] = not results[0][1]
	results[1][1] = not results[1][1]
	results[0][2] = not results[0][2]
if rounds[1][1] % 2 != 0:
	results[1][1] = not results[1][1]
	results[0][1] = not results[0][1]
	results[2][1] = not results[2][1]
	results[1][0] = not results[1][0]
	results[1][2] = not results[1][2]
if rounds[2][1] % 2 != 0:
	results[1][1] = not results[1][1]
	results[2][0] = not results[2][0]
	results[2][1] = not results[2][1]
	results[2][2] = not results[2][2]
if rounds[0][2] % 2 != 0:
	results[0][1] = not results[0][1]
	results[0][2] = not results[0][2]
	results[1][2] = not results[1][2]
if rounds[1][2] % 2 != 0:
	results[0][2] = not results[0][2]
	results[1][1] = not results[1][1]
	results[1][2] = not results[1][2]
	results[2][2] = not results[2][2]
if rounds[2][2] % 2 != 0:
	results[2][2] = not results[2][2]
	results[2][1] = not results[2][1]
	results[1][2] = not results[1][2]
i = 0
while i < 3:
	j = 0
	while j < 3:
		if results[i][j] == True:
			print(1, end='')
		else:
			print(0, end='')
		j += 1
	print('')
	i += 1


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
readint = lambda : int(sys.stdin.readline().rstrip('\r\n'))
readints = lambda : map(int, sys.stdin.readline().rstrip('\r\n').split())
readstr = lambda : sys.stdin.readline().rstrip('\r\n')
readstrs = lambda : map(str, sys.stdin.readline().rstrip('\r\n').split())
readarri = lambda : [int(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]
readarrs = lambda : [str(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]

def solve():
	mat = [readarri() for _ in range(3)]
	ans = [[1 for _ in range(3)] for __ in range(3)]
	for i in range(3):
		for j in range(3):
			if mat[i][j] & 1:
				ans[i][j] ^= 1
			if i == 0:
				if j == 0 and mat[i][j] & 1:
					ans[i][j + 1] ^= 1
					ans[i + 1][j] ^= 1
				elif j == 1 and mat[i][j] & 1:
					ans[i][j - 1] ^= 1
					ans[i + 1][j] ^= 1
					ans[i][j + 1] ^= 1
				elif j == 2 and mat[i][j] & 1:
					ans[i][j - 1] ^= 1
					ans[i + 1][j] ^= 1
			elif i == 1:
				if j == 0 and mat[i][j] & 1:
					ans[i - 1][j] ^= 1
					ans[i + 1][j] ^= 1
					ans[i][j + 1] ^= 1
				elif j == 1 and mat[i][j] & 1:
					ans[i][j - 1] ^= 1
					ans[i][j + 1] ^= 1
					ans[i - 1][j] ^= 1
					ans[i + 1][j] ^= 1
				elif j == 2 and mat[i][j] & 1:
					ans[i - 1][j] ^= 1
					ans[i + 1][j] ^= 1
					ans[i][j - 1] ^= 1
			elif i == 2:
				if j == 0 and mat[i][j] & 1:
					ans[i][j + 1] ^= 1
					ans[i - 1][j] ^= 1
				elif j == 1 and mat[i][j] & 1:
					ans[i][j - 1] ^= 1
					ans[i - 1][j] ^= 1
					ans[i][j + 1] ^= 1
				elif j == 2 and mat[i][j] & 1:
					ans[i][j - 1] ^= 1
					ans[i - 1][j] ^= 1
			else:
				assert False
	for i in ans:
		print(''.join([str(j) for j in i]))

def main():
	t = 1
	for _ in range(t):
		solve()
main()


def main():
	n = 3
	lights = [[], [], []]
	state = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
	for i in range(n):
		lights[i] = [int(_) for _ in input().split()]
	for i in range(n):
		for j in range(n):
			n_toggles = lights[i][j] + (lights[i - 1][j] if i > 0 else 0) + (lights[i + 1][j] if i < n - 1 else 0) + (lights[i][j - 1] if j > 0 else 0) + (lights[i][j + 1] if j < n - 1 else 0)
			state[i][j] = 1 - n_toggles % 2
	for i in range(n):
		print(''.join([str(value) for value in state[i]]))
main()


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


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


arran = []
arr = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
lst = [1, 0] * 5
zz = zo = zt = oz = oo = ot = tz = to = tt = 0
for i in range(3):
	arran.append(list(map(int, input().split())))
if arran[0][0] % 2 != 0:
	zz += 1
	zo += 1
	oz += 1
	arr[0][0] = lst[zz]
	arr[0][1] = lst[zo]
	arr[1][0] = lst[oz]
if arran[0][1] % 2 != 0:
	zz += 1
	zo += 1
	oo += 1
	zt += 1
	arr[0][0] = lst[zz]
	arr[0][1] = lst[zo]
	arr[1][1] = lst[oo]
	arr[0][2] = lst[zt]
if arran[0][2] % 2 != 0:
	zo += 1
	zt += 1
	ot += 1
	arr[0][1] = lst[zo]
	arr[0][2] = lst[zt]
	arr[1][2] = lst[ot]
if arran[1][0] % 2 != 0:
	zz += 1
	oo += 1
	oz += 1
	tz += 1
	arr[0][0] = lst[zz]
	arr[1][1] = lst[oo]
	arr[2][0] = lst[tz]
	arr[1][0] = lst[oz]
if arran[1][1] % 2 != 0:
	oz += 1
	oo += 1
	zo += 1
	to += 1
	ot += 1
	arr[1][0] = lst[oz]
	arr[1][1] = lst[oo]
	arr[0][1] = lst[zo]
	arr[2][1] = lst[to]
	arr[1][2] = lst[ot]
if arran[1][2] % 2 != 0:
	zt += 1
	ot += 1
	oo += 1
	tt += 1
	arr[0][2] = lst[zt]
	arr[1][2] = lst[ot]
	arr[1][1] = lst[oo]
	arr[2][2] = lst[tt]
if arran[2][0] % 2 != 0:
	oz += 1
	tz += 1
	to += 1
	arr[1][0] = lst[oz]
	arr[2][0] = lst[tz]
	arr[2][1] = lst[to]
if arran[2][1] % 2 != 0:
	tz += 1
	to += 1
	oo += 1
	tt += 1
	arr[2][0] = lst[tz]
	arr[2][1] = lst[to]
	arr[1][1] = lst[oo]
	arr[2][2] = lst[tt]
if arran[2][2] % 2 != 0:
	ot += 1
	tt += 1
	to += 1
	arr[1][2] = lst[ot]
	arr[2][2] = lst[tt]
	arr[2][1] = lst[to]
for i in arr:
	print(''.join(list(map(str, i))))


initial = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
mat = []
for i in range(3):
	m = list(map(int, input().split()))
	mat.append(m)
for row in range(3):
	for i in range(3):
		if mat[row][i] % 2 == 1:
			initial[row][i] = int(not initial[row][i])
			if row - 1 >= 0:
				initial[row - 1][i] = int(not initial[row - 1][i])
			if i - 1 >= 0:
				initial[row][i - 1] = int(not initial[row][i - 1])
			if row + 1 < 3:
				initial[row + 1][i] = int(not initial[row + 1][i])
			if i + 1 < 3:
				initial[row][i + 1] = int(not initial[row][i + 1])
for i in initial:
	print(*i, sep='')


a = [0, 0, 0]
for i in range(3):
	a[i] = list(map(int, input().split()))
b = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	for j in range(3):
		if i == 0 and j == 0:
			c = a[i][j] + a[i + 1][j] + a[i][j + 1]
			if c % 2 == 1:
				b[i][j] = 0
		if i == 0 and j == 1:
			c = a[i][j] + a[i + 1][j] + a[i][j + 1] + a[i][j - 1]
			if c % 2 == 1:
				b[i][j] = 0
		if i == 0 and j == 2:
			c = a[i][j] + a[i + 1][j] + a[i][j - 1]
			if c % 2 == 1:
				b[i][j] = 0
		if i == 1 and j == 0:
			c = a[i][j] + a[i + 1][j] + a[i][j + 1] + a[i - 1][j]
			if c % 2 == 1:
				b[i][j] = 0
		if i == 1 and j == 1:
			c = a[i][j] + a[i + 1][j] + a[i][j + 1] + a[i][j - 1] + a[i - 1][j]
			if c % 2 == 1:
				b[i][j] = 0
		if i == 1 and j == 2:
			c = a[i][j] + a[i - 1][j] + a[i][j - 1] + a[i + 1][j]
			if c % 2 == 1:
				b[i][j] = 0
		if i == 2 and j == 0:
			c = a[i][j] + a[i - 1][j] + a[i][j + 1]
			if c % 2 == 1:
				b[i][j] = 0
		if i == 2 and j == 1:
			c = a[i][j] + a[i - 1][j] + a[i][j - 1] + a[i][j + 1]
			if c % 2 == 1:
				b[i][j] = 0
		if i == 2 and j == 2:
			c = a[i][j] + a[i - 1][j] + a[i][j - 1]
			if c % 2 == 1:
				b[i][j] = 0
for i in range(3):
	x = [str(x) for x in b[i]]
	print(''.join(x))


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

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


line1 = list(map(int, input().split(' ')))
line2 = list(map(int, input().split(' ')))
line3 = list(map(int, input().split(' ')))
matrix = [line1, line2, line3]

def change_matrix(i, j):
	if i < 0 or j < 0:
		return
	try:
		final_matrix[i][j] = int(not final_matrix[i][j])
	except Exception as e:
		return
final_matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	for j in range(3):
		change = matrix[i][j] % 2
		if change:
			change_matrix(i, j)
			change_matrix(i + 1, j)
			change_matrix(i - 1, j)
			change_matrix(i, j + 1)
			change_matrix(i, j - 1)
for linha in final_matrix:
	print(''.join(map(str, linha)))


def adj(x, y):
	lst = []
	lst.append((x, y))
	if x - 1 >= 0:
		lst.append((x - 1, y))
	if y - 1 >= 0:
		lst.append((x, y - 1))
	if x + 1 <= 2:
		lst.append((x + 1, y))
	if y + 1 <= 2:
		lst.append((x, y + 1))
	return lst
initial = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
after_clicks = []
for i in range(3):
	after_clicks.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		if after_clicks[i][j] % 2 != 0:
			k = adj(i, j)
			for (x, y) in k:
				if initial[x][y] == 1:
					initial[x][y] = 0
				elif initial[x][y] == 0:
					initial[x][y] = 1
for i in initial:
	for j in i:
		print(j, end='')
	print('')


dim = 3
col = list()
bulb_matrix = list()

def mark_neighbours(i, j):
	if i >= 0 and i <= 2 and (j >= 0) and (j <= 2):
		bulb_matrix[i][j] = (bulb_matrix[i][j] + 1) % 2

def call_mark_neighbour(i, j):
	mark_neighbours(i, j)
	mark_neighbours(i - 1, j)
	mark_neighbours(i + 1, j)
	mark_neighbours(i, j + 1)
	mark_neighbours(i, j - 1)
for i in range(3):
	row = input().split()
	row = [int(i) for i in row]
	col.append(row)
	bulb_matrix.append([1, 1, 1])
for i in range(3):
	for j in range(3):
		if col[i][j] % 2 == 1:
			call_mark_neighbour(i, j)
for i in range(3):
	print(''.join(map(str, bulb_matrix[i])))


import sys
try:
	sys.stdin = open('inputs.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
finally:
	input = sys.stdin.readline
	print = sys.stdout.write
lights = [[1] * 3 for _ in range(3)]
toggle = []
for r in range(3):
	toggle.append(list(map(int, input().split())))
for r in range(3):
	for c in range(3):
		toggles = toggle[r][c]
		if r > 0:
			toggles += toggle[r - 1][c]
		if r < 2:
			toggles += toggle[r + 1][c]
		if c > 0:
			toggles += toggle[r][c - 1]
		if c < 2:
			toggles += toggle[r][c + 1]
		if toggles & 1:
			lights[r][c] = 0
	print(''.join(list(map(str, lights[r]))))
	print('\n')


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


lis = []
for i in range(3):
	a = list(map(int, input().split()))
	lis.append(a)
l1 = [[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 range(1, 4):
	for j in range(1, 4):
		k = lis[i - 1][j - 1]
		l1[i][j] += k
		l1[i][j - 1] += k
		l1[i][j + 1] += k
		l1[i - 1][j] += k
		l1[i + 1][j] += k
for i in range(3):
	for j in range(3):
		if l1[i + 1][j + 1] % 2 == 0:
			l1[i + 1][j + 1] = 1
		else:
			l1[i + 1][j + 1] = 0
for i in range(3):
	s = ''
	for j in range(3):
		s += str(l1[i + 1][j + 1])
	print(s)


(l1, l2, l3) = [int(a) for a in input().split()]
(l4, l5, l6) = [int(a) for a in input().split()]
(l7, l8, l9) = [int(a) for a in input().split()]
ini = [[l1 + l2 + l4, l1 + l2 + l3 + l5, l2 + l3 + l6], [l1 + l4 + l5 + l7, l2 + l4 + l5 + l6 + l8, l3 + l5 + l6 + l9], [l4 + l7 + l8, l5 + l7 + l8 + l9, l6 + l8 + l9]]
for i in range(3):
	print(''.join([str(int(a % 2 == 0)) for a in ini[i]]))


a = []
for i in range(3):
	a.append(list(map(int, input().split())))
print((a[0][0] + a[1][0] + a[0][1] + 1) % 2, (a[0][0] + a[0][2] + a[0][1] + a[1][1] + 1) % 2, (a[0][2] + a[0][1] + a[1][2] + 1) % 2, sep='')
print((a[1][0] + a[0][0] + a[1][1] + a[2][0] + 1) % 2, (a[1][1] + a[0][1] + a[1][0] + a[2][1] + a[1][2] + 1) % 2, (a[1][2] + a[1][1] + a[0][2] + a[2][2] + 1) % 2, sep='')
print((a[2][0] + a[1][0] + a[2][1] + 1) % 2, (a[2][0] + a[1][1] + a[2][1] + a[2][2] + 1) % 2, (a[2][2] + a[2][1] + a[1][2] + 1) % 2, sep='')


from sys import stdin
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
v = []
for _ in range(3):
	v += [mp()]
k = [[0 for _ in range(3)] for _ in range(3)]
for i in range(3):
	for j in range(3):
		if i == 0:
			if j == 0:
				k[i][j] += v[i][j + 1] + v[i + 1][j] + v[i][j]
			elif j == 1:
				k[i][j] = v[i][j - 1] + v[i][j + 1] + v[i + 1][j] + v[i][j]
			else:
				k[i][j] += v[i][j - 1] + v[i + 1][j] + v[i][j]
		elif i == 1:
			if j == 0:
				k[i][j] += v[i][j + 1] + v[i + 1][j] + v[i - 1][j] + v[i][j]
			elif j == 1:
				k[i][j] += v[i][j - 1] + v[i][j + 1] + v[i + 1][j] + v[i - 1][j] + v[i][j]
			else:
				k[i][j] += v[i][j - 1] + v[i + 1][j] + v[i - 1][j] + v[i][j]
		elif j == 0:
			k[i][j] += v[i][j + 1] + v[i - 1][j] + v[i][j]
		elif j == 1:
			k[i][j] += v[i][j - 1] + v[i][j + 1] + v[i - 1][j] + v[i][j]
		else:
			k[i][j] += v[i][j - 1] + v[i - 1][j] + v[i][j]
for i in range(3):
	for j in range(3):
		if k[i][j] & 1:
			k[i][j] = 0
		else:
			k[i][j] = 1
for i in range(3):
	print(*k[i], sep='')


mat = []
sarr = []
s = ''
for i in range(3):
	a = list(map(int, input().split()))
	mat.append(a)
ansarr = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
ansarr[0][0] = mat[0][0] + mat[0][1] + mat[1][0]
ansarr[0][1] = mat[0][1] + mat[0][2] + mat[1][1] + mat[0][0]
ansarr[0][2] = mat[0][2] + mat[0][1] + mat[1][2]
ansarr[1][0] = mat[1][0] + mat[0][0] + mat[1][1] + mat[2][0]
ansarr[1][1] = mat[1][1] + mat[0][1] + mat[1][0] + mat[1][2] + mat[2][1]
ansarr[1][2] = mat[1][2] + mat[0][2] + mat[1][1] + mat[2][2]
ansarr[2][0] = mat[2][0] + mat[1][0] + mat[2][1]
ansarr[2][1] = mat[2][1] + mat[1][1] + mat[2][0] + mat[2][2]
ansarr[2][2] = mat[2][2] + mat[1][2] + mat[2][1]
for i in range(3):
	for j in range(3):
		if ansarr[i][j] % 2:
			s += '0'
		else:
			s += '1'
	sarr.append(s)
	s = ''
for i in sarr:
	print(i)


l1 = [[1] * 3 for _ in range(3)]
l2 = []
for i in range(3):
	l2.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		if l2[i][j] % 2 == 1:
			l1[i][j] ^= 1
			if i < 2:
				l1[i + 1][j] ^= 1
			if i > 0:
				l1[i - 1][j] ^= 1
			if j > 0:
				l1[i][j - 1] ^= 1
			if j < 2:
				l1[i][j + 1] ^= 1
for item in l1:
	print(''.join((str(x) for x in item)))


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


def valid(i, j):
	if i >= 0 and i <= 2 and (j >= 0) and (j <= 2):
		return True
	else:
		return False
mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]

def do_thing(i, j):
	mat[i][j] = 1 - mat[i][j]
	if valid(i + 1, j):
		mat[i + 1][j] = 1 - mat[i + 1][j]
	if valid(i, j + 1):
		mat[i][j + 1] = 1 - mat[i][j + 1]
	if valid(i - 1, j):
		mat[i - 1][j] = 1 - mat[i - 1][j]
	if valid(i, j - 1):
		mat[i][j - 1] = 1 - mat[i][j - 1]
l = []
for i in range(3):
	l.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		if l[i][j] % 2 == 1:
			do_thing(i, j)
for i in mat:
	print(*i, sep='')


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(' ')]
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]
		a[c] = 1 if a[c] % 2 == 0 else 0
		print(a[c], end='')
		c += 1
	print()


i = 0
a = []
r = [0] * 9
while i < 3:
	l = input().split(' ')
	a = a + [int(l[0]), int(l[1]), int(l[2])]
	i = i + 1
r[0] = a[0] + a[1] + a[3]
r[1] = a[1] + a[0] + a[2] + a[4]
r[2] = a[2] + a[1] + a[5]
r[3] = a[3] + a[0] + a[6] + a[4]
r[4] = a[4] + a[1] + a[3] + a[5] + a[7]
r[5] = a[5] + a[2] + a[8] + a[4]
r[6] = a[6] + a[3] + a[7]
r[7] = a[7] + a[4] + a[6] + a[8]
r[8] = a[8] + a[5] + a[7]
i = 0
while i < len(r):
	r[i] = (r[i] + 1) % 2
	i = i + 1
i = 0
while i < 9:
	print(str(r[i]) + str(r[i + 1]) + str(r[i + 2]))
	i = i + 3


line = []
for _ in range(3):
	line.append(list(map(int, input().split())))
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])))


ls = []

def convert(value):
	if value == 0:
		return 1
	else:
		return 0
arr = [[1 for col in range(3)] for row in range(3)]
for _ in range(3):
	ls.append([int(x) for x in input().split()])
for row in range(3):
	for column in range(3):
		if ls[row][column] % 2 == 0:
			continue
		else:
			arr[row][column] = convert(arr[row][column])
			if row != 0:
				arr[row - 1][column] = convert(arr[row - 1][column])
			if column != 0:
				arr[row][column - 1] = convert(arr[row][column - 1])
			try:
				arr[row + 1][column] = convert(arr[row + 1][column])
			except:
				pass
			try:
				arr[row][column + 1] = convert(arr[row][column + 1])
			except:
				pass
for ind in range(3):
	a = map(str, arr[ind])
	print(''.join(a))


a = []
for i in range(3):
	a.append([int(j) for j in input().split()])
l = []
for i in range(3):
	l.append([0] * 3)
l[0][0] = (a[0][0] + a[1][0] + a[0][1] + 1) % 2
l[2][2] = (a[2][2] + a[1][2] + a[2][1] + 1) % 2
l[2][0] = (a[2][0] + a[1][0] + a[2][1] + 1) % 2
l[0][2] = (a[0][2] + a[1][2] + a[0][1] + 1) % 2
l[1][0] = (a[1][0] + a[2][0] + a[1][1] + a[0][0] + 1) % 2
l[0][1] = (a[0][1] + a[0][2] + a[1][1] + a[0][0] + 1) % 2
l[1][2] = (a[1][2] + a[0][2] + a[1][1] + a[2][2] + 1) % 2
l[2][1] = (a[2][1] + a[2][0] + a[1][1] + a[2][2] + 1) % 2
l[1][1] = (a[1][1] + a[0][1] + a[1][0] + a[2][1] + a[1][2] + 1) % 2
for row in l:
	print(''.join([str(el) for el in row]))


import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda : list(map(int, input().split()))

def main():
	mat = []
	grid = []
	for _ in range(3):
		mat.append(ARR())
		grid.append([1] * 3)
	for i in range(3):
		for j in range(3):
			if mat[i][j] % 2:
				grid[i][j] = not grid[i][j]
				if i - 1 >= 0:
					grid[i - 1][j] = not grid[i - 1][j]
				if i + 1 < 3:
					grid[i + 1][j] = not grid[i + 1][j]
				if j - 1 >= 0:
					grid[i][j - 1] = not grid[i][j - 1]
				if j + 1 < 3:
					grid[i][j + 1] = not grid[i][j + 1]
	for i in range(3):
		for j in range(3):
			print(int(grid[i][j]), end='')
		print()
main()


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


lights = [[True, True, True], [True, True, True], [True, True, True]]
inp = []
for _ in range(3):
	ro2 = [int(x) for x in input().split()]
	inp.append(ro2)
for i in range(3):
	for j in range(3):
		if inp[i][j] % 2 == 0:
			continue
		else:
			lights[i][j] = not lights[i][j]
			if i != 0:
				lights[i - 1][j] = not lights[i - 1][j]
			if i != 2:
				lights[i + 1][j] = not lights[i + 1][j]
			if j != 0:
				lights[i][j - 1] = not lights[i][j - 1]
			if j != 2:
				lights[i][j + 1] = not lights[i][j + 1]
for i in range(3):
	for j in range(3):
		print(1 if lights[i][j] else 0, end='')
	print()


import sys
input = sys.stdin.readline

def inlt():
	return list(map(int, input().split()))

def solve(m):

	def helper(mat, i, j):
		direction = [(0, 0), (-1, 0), (1, 0), (0, -1), (0, 1)]
		for d in direction:
			if i + d[0] > -1 and i + d[0] < 3 and (j + d[1] > -1) and (j + d[1] < 3):
				if mat[i + d[0]][j + d[1]] == 0:
					mat[i + d[0]][j + d[1]] = 1
				else:
					mat[i + d[0]][j + d[1]] = 0
		return mat
	mat = [[1] * 3 for _ in range(3)]
	for r in range(3):
		for c in range(3):
			if m[r][c] % 2 != 0:
				mat = helper(mat, r, c)
	return mat
m = []
for i in range(3):
	m.append(inlt())
mat = solve(m)
for i in range(3):
	print(''.join(map(str, mat[i])))


toggle = []
for i in range(3):
	toggle.append(list(map(int, input().split())))
l = [[0] * 5 for i in range(5)]
for i in range(1, 4):
	l[i][1:4] = toggle[i - 1]
for i in range(1, 4):
	for j in range(1, 4):
		print((1 + l[i][j] + l[i][j - 1] + l[i - 1][j] + l[i + 1][j] + l[i][j + 1]) % 2, end='')
	print()


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


(a, b, c) = map(int, input().split())
(d, e, f) = map(int, input().split())
(g, h, i) = map(int, input().split())
print((a + b + d + 1) % 2, (a + b + c + e + 1) % 2, (b + c + f + 1) % 2, sep='')
print((a + d + e + g + 1) % 2, (b + d + e + f + h + 1) % 2, (c + e + f + i + 1) % 2, sep='')
print((d + g + h + 1) % 2, (e + g + h + i + 1) % 2, (f + h + i + 1) % 2, sep='')


def change(n):
	if n == 0:
		n = 1
	else:
		n = 0
	return n
table = []
for i in range(3):
	table.append(list(map(int, input().split())))
row = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	for j in range(3):
		if table[i][j] % 2 == 0:
			continue
		else:
			row[i][j] = change(row[i][j])
			if i == 0:
				if j == 0:
					row[i][j + 1] = change(row[i][j + 1])
					row[i + 1][j] = change(row[i + 1][j])
				elif j == 1:
					row[i][j + 1] = change(row[i][j + 1])
					row[i][j - 1] = change(row[i][j - 1])
					row[i + 1][j] = change(row[i + 1][j])
				elif j == 2:
					row[i][j - 1] = change(row[i][j - 1])
					row[i + 1][j] = change(row[i + 1][j])
			elif i == 1:
				if j == 0:
					row[i][j + 1] = change(row[i][j + 1])
					row[i - 1][j] = change(row[i - 1][j])
					row[i + 1][j] = change(row[i + 1][j])
				elif j == 1:
					row[i][j + 1] = change(row[i][j + 1])
					row[i][j - 1] = change(row[i][j - 1])
					row[i + 1][j] = change(row[i + 1][j])
					row[i - 1][j] = change(row[i - 1][j])
				elif j == 2:
					row[i][j - 1] = change(row[i][j - 1])
					row[i + 1][j] = change(row[i + 1][j])
					row[i - 1][j] = change(row[i - 1][j])
			elif i == 2:
				if j == 0:
					row[i][j + 1] = change(row[i][j + 1])
					row[i - 1][j] = change(row[i - 1][j])
				elif j == 1:
					row[i][j + 1] = change(row[i][j + 1])
					row[i][j - 1] = change(row[i][j - 1])
					row[i - 1][j] = change(row[i - 1][j])
				elif j == 2:
					row[i - 1][j] = change(row[i - 1][j])
					row[i][j - 1] = change(row[i][j - 1])
for i in range(3):
	rowo = ''
	for j in range(3):
		rowo += str(row[i][j])
	print(rowo)


res = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
arr = [[int(i) for i in input().split()] for j in range(3)]
for x in range(3):
	for y in range(3):
		if arr[x][y] % 2 == 0:
			continue
		res[x][y] *= -1
		if y > 0:
			res[x][y - 1] *= -1
		if y < 2:
			res[x][y + 1] *= -1
		if x > 0:
			res[x - 1][y] *= -1
		if x < 2:
			res[x + 1][y] *= -1
for i in range(3):
	for j in range(3):
		print(res[i][j] * (res[i][j] > 0), end='')
	print()


def getAdj(a, b):
	pos_x = [a]
	if a - 1 >= 0:
		pos_x.append(a - 1)
	if a + 1 <= 2:
		pos_x.append(a + 1)
	pos_y = [b]
	if b - 1 >= 0:
		pos_y.append(b - 1)
	if b + 1 <= 2:
		pos_y.append(b + 1)
	fin = []
	for x in pos_x:
		fin.append((x, b))
	for y in pos_y:
		if y != b:
			fin.append((a, y))
	return fin
mat = [['1' for i in range(3)] for j in range(3)]
for i in range(3):
	lst = list(map(int, input().split(' ')))
	for j in range(3):
		if lst[j] != 0:
			for pt in getAdj(i, j):
				if lst[j] % 2 == 1:
					mat[pt[0]][pt[1]] = '0' if mat[pt[0]][pt[1]] == '1' else '1'
for i in range(len(mat)):
	print(''.join(mat[i]))


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


def check(i, j):
	if i >= 0 and j >= 0 and (j <= 2) and (i <= 2):
		return True
	return False
arr = []
for _ in range(3):
	arr.append(list(map(int, input().split())))
ans = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for i in range(3):
	for j in range(3):
		if arr[i][j] % 2:
			ans[i][j] ^= 1
			if check(i + 1, j):
				ans[i + 1][j] ^= 1
			if check(i - 1, j):
				ans[i - 1][j] ^= 1
			if check(i, j + 1):
				ans[i][j + 1] ^= 1
			if check(i, j - 1):
				ans[i][j - 1] ^= 1
for i in ans:
	print(*i, sep='')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ls = []
js = []
ab = [1, 1, 1]
for i in range(3):
	js.append(ab[:])
for i in range(3):
	lsin = list(map(int, input().rstrip().split()))
	for j in range(3):
		for k in range(lsin[j]):
			js[i][j] += 1
			if i + 1 < 3:
				js[i + 1][j] += 1
			if i - 1 >= 0:
				js[i - 1][j] += 1
			if j + 1 < 3:
				js[i][j + 1] += 1
			if j - 1 >= 0:
				js[i][j - 1] += 1

def de(j):
	return str(j % 2)
for i in js:
	print(''.join(map(de, i)))


t = []
for i in range(3):
	l = list(map(int, input().split()))
	t.append(l)
for i in range(3):
	for j in range(3):
		if i == 0 and j == 0:
			t1 = t[0][0] + t[0][1] + t[1][0]
			if t1 % 2 == 0:
				print(1, end='')
			else:
				print(0, end='')
		elif i == 0 and j == 1:
			t1 = t[0][1] + t[0][0] + t[0][2] + t[1][1]
			if t1 % 2 == 0:
				print(1, end='')
			else:
				print(0, end='')
		elif i == 0 and j == 2:
			t1 = t[0][2] + t[1][2] + t[0][1]
			if t1 % 2 == 0:
				print(1, end='')
			else:
				print(0, end='')
		elif i == 1 and j == 0:
			t1 = t[1][0] + t[0][0] + t[2][0] + t[1][1]
			if t1 % 2 == 0:
				print(1, end='')
			else:
				print(0, end='')
		elif i == 1 and j == 1:
			t1 = t[1][1] + t[0][1] + t[2][1] + t[1][0] + t[1][2]
			if t1 % 2 == 0:
				print(1, end='')
			else:
				print(0, end='')
		elif i == 1 and j == 2:
			t1 = t[1][2] + t[1][1] + t[0][2] + t[2][2]
			if t1 % 2 == 0:
				print(1, end='')
			else:
				print(0, end='')
		elif i == 2 and j == 0:
			t1 = t[2][0] + t[1][0] + t[2][1]
			if t1 % 2 == 0:
				print(1, end='')
			else:
				print(0, end='')
		elif i == 2 and j == 1:
			t1 = t[2][1] + t[2][0] + t[1][1] + t[2][2]
			if t1 % 2 == 0:
				print(1, end='')
			else:
				print(0, end='')
		elif i == 2 and j == 2:
			t1 = t[2][2] + t[2][1] + t[1][2]
			if t1 % 2 == 0:
				print(1, end='')
			else:
				print(0, end='')
	print()


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


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)


mat = [[0, 0, 0, 0, 0]]
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('')


mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for x in range(3):
	for (y, t) in enumerate(map(int, input().split())):
		if t % 2 == 0:
			continue
		mat[x][y] *= -1
		if y > 0:
			mat[x][y - 1] *= -1
		if y < 2:
			mat[x][y + 1] *= -1
		if x > 0:
			mat[x - 1][y] *= -1
		if x < 2:
			mat[x + 1][y] *= -1
for row in mat:
	for x in row:
		print(x * (x > 0), end='')
	print()


x1 = [int(x) for x in input().split()]
x2 = [int(x) for x in input().split()]
x3 = [int(x) for x in input().split()]
(x11, x12, x13) = x1
(x21, x22, x23) = x2
(x31, x32, x33) = x3
endliste = [[], [], []]
if (x11 + x12 + x21) % 2 == 0:
	endliste[0].append('1')
else:
	endliste[0].append('0')
if (x11 + x12 + x13 + x22) % 2 == 0:
	endliste[0].append('1')
else:
	endliste[0].append('0')
if (x13 + x12 + x23) % 2 == 0:
	endliste[0].append('1')
else:
	endliste[0].append('0')
if (x11 + x22 + x31 + x21) % 2 == 0:
	endliste[1].append('1')
else:
	endliste[1].append('0')
if (x22 + x12 + x32 + x21 + x23) % 2 == 0:
	endliste[1].append('1')
else:
	endliste[1].append('0')
if (x23 + x13 + x33 + x22) % 2 == 0:
	endliste[1].append('1')
else:
	endliste[1].append('0')
if (x31 + x21 + x32) % 2 == 0:
	endliste[2].append('1')
else:
	endliste[2].append('0')
if (x32 + x31 + x33 + x22) % 2 == 0:
	endliste[2].append('1')
else:
	endliste[2].append('0')
if (x33 + x32 + x23) % 2 == 0:
	endliste[2].append('1')
else:
	endliste[2].append('0')
for elem in endliste:
	print(''.join(elem))


import sys
import math
import collections
from collections import deque
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))))
b = []
a = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
for _ in range(3):
	b.append(list(map(int, stdin.readline().split())))
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 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('')


count = [0, 0, 0, 0, 0, 0, 0, 0, 0]
tally = {1: [4, 1, 2], 2: [2, 1, 3, 5], 3: [3, 2, 6], 4: [5, 7, 4, 1], 5: [2, 5, 6, 8, 4], 6: [3, 6, 5, 9], 7: [4, 7, 8], 8: [5, 7, 8, 9], 9: [6, 8, 9]}
given = []
for i in range(3):
	(a, b, c) = map(int, input().split())
	given.append(a)
	given.append(b)
	given.append(c)
for i in range(1, 10):
	lincrement = tally[i]
	increment_value = given[i - 1]
	for i in lincrement:
		count[i - 1] += increment_value
myl = []
for i in range(1, 10):
	if count[i - 1] % 2 == 0:
		myl.append('1')
	elif count[i - 1] % 2 != 0:
		myl.append('0')
	if i % 3 == 0:
		print(''.join(myl))
		myl = []


lights = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
i = 0
j = 0
a = 0
press = []
while a <= 2:
	line = []
	(x, y, z) = input().split()
	line.append(int(x))
	line.append(int(y))
	line.append(int(z))
	press.append(line)
	a = a + 1
while i <= 2:
	j = 0
	while j <= 2:
		if i == 1 and j == 1:
			lights[i][j] = 1 + press[i][j] + press[i + 1][j] + press[i][j + 1] + press[i - 1][j] + press[i][j - 1]
		elif i == 0 and j == 1:
			lights[i][j] = 1 + press[0][0] + press[0][2] + press[1][1] + press[0][1]
		elif i == 2 and j == 1:
			lights[i][j] = 1 + press[2][0] + press[2][2] + press[1][1] + press[2][1]
		elif i == 0 and j == 0:
			lights[i][j] = 1 + press[0][0] + press[0][1] + press[1][0]
		elif i == 0 and j == 2:
			lights[i][j] = 1 + press[0][2] + press[0][1] + press[1][2]
		elif i == 1 and j == 0:
			lights[i][j] = 1 + press[0][0] + press[1][1] + press[2][0] + press[1][0]
		elif i == 1 and j == 2:
			lights[i][j] = 1 + press[0][2] + press[1][1] + press[2][2] + press[1][2]
		elif j == 0 and i == 2:
			lights[i][j] = 1 + press[2][0] + press[1][0] + press[2][1]
		elif j == 2 and i == 2:
			lights[i][j] = 1 + press[2][2] + press[1][2] + press[2][1]
		j = j + 1
	i = i + 1
i = 0
j = 0
while i <= 2:
	j = 0
	while j <= 2:
		if lights[i][j] % 2 == 0:
			lights[i][j] = 0
		else:
			lights[i][j] = 1
		j = j + 1
	i = i + 1
i = 0
j = 0
while i <= 2:
	j = 0
	while j <= 2:
		lights[i][j] = str(lights[i][j])
		j = j + 1
	i = i + 1
print(''.join(lights[0]))
print(''.join(lights[1]))
print(''.join(lights[2]))


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