import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static char div[][] = { { 'a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c' },
{ 'a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c' }, { 'a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c' },
{ 'd', 'd', 'd', 'e', 'e', 'e', 'f', 'f', 'f' }, { 'd', 'd', 'd', 'e', 'e', 'e', 'f', 'f', 'f' },
{ 'd', 'd', 'd', 'e', 'e', 'e', 'f', 'f', 'f' }, { 'g', 'g', 'g', 'h', 'h', 'h', 'i', 'i', 'i' },
{ 'g', 'g', 'g', 'h', 'h', 'h', 'i', 'i', 'i' }, { 'g', 'g', 'g', 'h', 'h', 'h', 'i', 'i', 'i' }, };
static boolean rowsChk[][] = new boolean[10][10];
static boolean colsChk[][] = new boolean[10][10];
static boolean divChk[][] = new boolean[10][10];
static int list[][] = new int[10][10];
static boolean func(int x, int y) {
if (x == 9) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
sb.append(list[i][j]);
}
sb.append("\n");
}
System.out.println(sb.toString());
return true;
}
int nx = x;
int ny = y + 1;
if (ny == 9) {
nx++;
ny = 0;
}
if (list[x][y] != 0)
return func(nx, ny);
else {
for (int i = 1; i <= 9; i++) {
if (rowsChk[x][i] || colsChk[y][i] || divChk[div[x][y] - 'a'][i])
continue;
rowsChk[x][i] = true;
colsChk[y][i] = true;
divChk[div[x][y] - 'a'][i] = true;
list[x][y] = i;
boolean chk = func(nx, ny);
if (chk)
return true;
list[x][y] = 0;
divChk[div[x][y] - 'a'][i] = false;
colsChk[y][i] = false;
rowsChk[x][i] = false;
}
}
return false;
}
static void input() throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
char ch[];
for (int i = 0; i < 9; i++) {
st = new StringTokenizer(br.readLine());
ch = st.nextToken().toCharArray();
for (int j = 0; j < 9; j++) {
list[i][j] = ch[j] - '0';
if (list[i][j] != 0) {
rowsChk[i][list[i][j]] = true;
colsChk[j][list[i][j]] = true;
divChk[div[i][j] - 'a'][list[i][j]] = true;
}
}
}
}
public static void main(String[] args) throws Exception {
input();
func(0, 0);
}
}