anthouse = []
for i in range(10):
v = list(map(int, input().split()))
anthouse.append(v)
x = 1
y = 1
if anthouse[x][y] == 2:
anthouse[x][y] = 0
else:
anthouse[x][y] = 9
while True:
if y<=7 and anthouse[x][y+1] == 0:
y = y + 1
anthouse[x][y] = 9
elif y<=7 and anthouse[x][y+1] == 2:
anthouse[x][y] = 9
break
else:
if x<=7 and y<=7 and anthouse[x][y+1] == 1 and anthouse[x+1][y] == 0:
x = x + 1
y = anthouse[x][y] = 9
elif anthouse[x+1][y] == 1:
break
else:
x = x + 1
anthouse[x][y] = 9
break
for i in range (10):
for j in range(10):
print(anthouse[i][j], end = ' ')
print('\n', end = '')