# include <stdio.h>
int main() {
int i, j, x, y;
int e[100][100]= {0,};
for(i=1; i<=10; i++) {
for(j=1; j<=10; j++) {
scanf("%d",&e[i][j]);
}
}
x = 2;
y = 2;
if(e[x][y] == 2) {
e[x][y] = 9;
} else {
e[x][y]=9;
for(;;) {
if(e[x][y+1] == 0) {
y++;
e[x][y] = 9;
} else if(e[x][y+1] == 2) {
y++;
e[x][y]=9;
break;
} else if(e[x][y+1] == 1) {
if(e[x+1][y]==1) {
break;
}
else {
if(e[x+1][y]==0){
x++;
e[x][y]=9;
}
else if(e[x+1][y]==2){
x++;
e[x][y]=9;
break;
}
}
}
}
}
for(i=1; i<=10; i++) {
for(j=1; j<=10; j++) {
printf("%d ",e[i][j]);
}
printf("\n");
}
return 0;
}



