#include<bits/stdc++.h>
using namespace std;
int num,a[15][15];
bool hx[15][15],lx[15][15],fg[9];
int fg_;
void fz(int x,int y){
if(x%3==0){
if(y%3==0) fg_=(x/3-1)*3+y/3;
else fg_=(x/3-1)+y/3+1;
return;
}
if(y%3==0) fg_=x+y/3;
}
void dfs(int x,int y){
if(x==10){
for(int i=1;i<=9;i++){
for(int j=1;j<=9;j++)
printf("%d ",a[i][j]);
printf("\n");
}
exit(0);
}
if(a[x][y]!=0){
if(y==9)
dfs(x+1,1);
else
dfs(x,y+1);
}
else{
for(int i=1;i<=9;i++){
if(hx[x][i]==0&&lx[y][i]==0){
a[x][y]=i;
hx[x][i]=1;
lx[y][i]=1;
fz(x,y);
fg[fg_]=1;
if(y==9) dfs(x+1,1);
else dfs(x,y+1);
hx[x][i]=0;
lx[y][i]=0;
fg[fg_]=0;
}
}
}
}
int main(){
int x;
for(int i=1;i<=9;i++)
for(int j=1;j<=9;j++){
cin>>x;
if(x!=0){
hx[i][x]=1;
lx[j][x]=1;
a[i][j]=x;
}
}
dfs(1,1);
return 0;
}