import java.util.Scanner;
class stoku {
Scanner sc1 = new Scanner(System.in);
int[][] board = new int[9][9];
boolean[][] row = new boolean[9][10];
boolean[][] col = new boolean[9][10];
boolean[][] square = new boolean[9][10] ;
boolean pri;
public void insert(){
for(int i=0; i<9 ;i++){
for(int j=0; j<9 ;j++) {
board[i][j]=sc1.nextInt();
switch (board[i][j]){
case 1: row[i][1] = true; col[j][1] = true; square[(i/3)*3+(j/3)][1] = true; break;
case 2: row[i][2] = true; col[j][2] = true; square[(i/3)*3+(j/3)][2] = true; break;
case 3: row[i][3] = true; col[j][3] = true; square[(i/3)*3+(j/3)][3] = true; break;
case 4: row[i][4] = true; col[j][4] = true; square[(i/3)*3+(j/3)][4] = true; break;
case 5: row[i][5] = true; col[j][5] = true; square[(i/3)*3+(j/3)][5] = true; break;
case 6: row[i][6] = true; col[j][6] = true; square[(i/3)*3+(j/3)][6] = true; break;
case 7: row[i][7] = true; col[j][7] = true; square[(i/3)*3+(j/3)][7] = true; break;
case 8: row[i][8] = true; col[j][8] = true; square[(i/3)*3+(j/3)][8] = true; break;
case 9: row[i][9] = true; col[j][9] = true; square[(i/3)*3+(j/3)][9] = true; break;
}
}
}
}
public boolean hasZero() {
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if(board[i][j] == 0) {
return true;
}
}
}
pri = true;
return false;
}
public void start() {
for (int i = 0; i <9; i++) {
for (int j = 0; j < 9; j++) {
if(board[i][j] == 0) {
for (int k = 1; k <= 9; k++) {
if ((!row[i][k]) && (!col[j][k]) && (!square[(i / 3) * 3 + (j / 3)][k]) ) {
board[i][j] = k;
row[i][k] = true;
col[j][k] = true;
square[(i / 3) * 3 + (j / 3)][k] = true;
if (!hasZero())return;
start();
if(!pri){
board[i][j] = 0;
row[i][k] = false;
col[j][k] = false;
square[(i / 3) * 3 + (j / 3)][k] = false;
}
}
}
}
}
}
}
//출력
public void getBoard(){
for(int i=0; i<9 ;i++){
for(int j=0; j<9 ;j++) {
System.out.printf("%d ",board[i][j]);
}
System.out.println();
}
}
}
public class _2580{
public static void main(String[] args) {
stoku s1 = new stoku();
s1.insert();
s1.start();
s1.getBoard();
}
}