#include<iostream>
using namespace std;
int a[10][10];
bool zong[10][10],heng[10][10],jubu[10][10],flag = 0;
int in (int x,int y){
if(x <= 3 && y <= 3){
return 1;
}if(x >3 && x <= 6 && y <= 3){
return 2;
}if(x > 6 & x <= 9 && y <= 3){
return 3;
}if(x <= 3 && y > 3 && y <= 6){
return 4;
}if(x > 3 && x <= 6 && y > 3 && y <= 6){
return 5;
}if( x >6 && x <= 9 && y > 3 && y <= 6){
return 6;
}if(x <= 3 && y > 6 & y <= 9){
return 7;
}if( x > 3 && x <= 6 && y > 6 && y <= 9){
return 8;
}if(x > 6 && x <= 9 & y > 6 && y <= 9){
return 9;
}
}
void cmp(){
for(int i = 1; i <= 9; i ++){
for(int j = 1; j <= 9; j++){
cout << a[i][j] << " ";
}cout << endl;
}return;
}
void dfs(int x,int y){
if(flag)return;
if(x == 10){
flag = 1;
cmp();
return;
}
if(a[x][y] == 0){
for(int i = 1; i <= 9; i++){
if(!zong[y][i] && ! heng[x][i] && !jubu[in(x,y)][i]){
a[x][y] = i;
zong[y][i] = heng[x][i] = jubu[in(x,y)][i] = 1;
if(y < 9){
dfs(x,y + 1);
}else{
dfs(x + 1,1);
}
a[x][y] = 0;
zong[y][i] = heng[x][i] = jubu[in(x,y)][i] = 0;
}else{
if(y < 9){
dfs(x, y + 1);
}else{
dfs(x + 1,1);
}
}
}
}
}
int main(){
for(int i = 1; i <= 9; i++){
for(int j = 1; j <= 9; j++){
cin >> a[i][j];
zong[j][a[i][j]] = 1;
heng[i][a[i][j]] = 1;
jubu[in(i,j)][a[i][j]] = 1;
}
}
dfs(1,1);
return 0;
}