#include <cstdio>
#include <cstdlib>
using namespace std;
int board[9+2][9+2];
bool Const[9+2][9+2];
bool row[9+2][9+2], col[9+2][9+2], pal[9+2][9+2];
int PAL[9+2][9+2]={
{1, 1, 1, 2, 2, 2, 3, 3, 3},
{1, 1, 1, 2, 2, 2, 3, 3, 3},
{1, 1, 1, 2, 2, 2, 3, 3, 3},
{4, 4, 4, 5, 5, 5, 6, 6, 6},
{4, 4, 4, 5, 5, 5, 6, 6, 6},
{4, 4, 4, 5, 5, 5, 6, 6, 6},
{7, 7, 7, 8, 8, 8, 9, 9, 9},
{7, 7, 7, 8, 8, 8, 9, 9, 9},
{7, 7, 7, 8, 8, 8, 9, 9, 9},
};
void Print(){
for(int r = 0; r<9; ++r){
printf("%d", board[r][0]);
for(int c = 1; c<9; ++c) printf(" %d", board[r][c]);
printf("\n");
}
}
void DFS(int r, int c){
if(r>8){
Print();
exit(0);
}
if(c>8){
DFS(r+1, 0);
return;
}
if(Const[r][c]){
DFS(r, c+1);
return;
}
for(int i = 1; i<=9; ++i){
if(!row[r][i] && !col[c][i] && !pal[PAL[r][c]][i]){
board[r][c] = i;
row[r][i] = col[c][i] = pal[PAL[r][c]][i] = true;
DFS(r, c+1);
row[r][i] = col[c][i] = pal[PAL[r][c]][i] = false;
}
}
}
int main(){
for(int y = 0; y<9; ++y) for(int x = 0; x<9; ++x){
scanf("%d", &board[y][x]);
if(board[y][x]){
Const[y][x] = true;
row[y][board[y][x]] = true;
col[x][board[y][x]] = true;
pal[PAL[y][x]][board[y][x]] = true;
}
}
DFS(0, 0);
return 0;
}