#include <iostream>
using namespace std;
#define MAXN 9
int bit_row[MAXN];
int bit_col[MAXN];
int bit_box[MAXN];
char map[MAXN][MAXN];
int total_cnt = 0;
bool flag = false;
bool check(int x, int y, int num) {
if ((bit_row[x] & (1 << num)) ||
(bit_col[y] & (1 << num)) ||
(bit_box[int(x/3)*3+y/3] & (1<<num))) return false;
return true;
}
void dfs(int x, int y, int cnt) {
if (flag) return;
if (cnt == total_cnt) {
flag = true;
for (int i = 0; i < MAXN; i++) {
for (int j = 0; j < MAXN; j++) {
cout << map[i][j];
}
cout << "\n";
}
return;
}
if (y == MAXN) dfs(x + 1, 0, cnt);
if (map[x][y] != '0') dfs(x, y + 1, cnt);
else {
for (int i = 1; i <= 9; i++) {
if (check(x, y, i)) {
bit_row[x] |= (1 << i);
bit_col[y] |= (1 << i);
bit_box[int(x / 3) * 3 + y / 3] |= (1 << i);
map[x][y] = i + '0';
dfs(x, y + 1, cnt + 1);
bit_row[x] &= ~(1 << i);
bit_col[y] &= ~(1 << i);
bit_box[int(x / 3) * 3 + y / 3] &= ~(1 << i);
}
}
map[x][y] = '0';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
for (int i = 0; i < MAXN; i++) {
cin >> map[i];
for (int j = 0; j < MAXN; j++) {
if (map[i][j] == '0') total_cnt++;
}
}
for (int i = 0; i < MAXN; i++) {
for (int j = 0; j < MAXN; j++) {
if (map[i][j] != '0') {
bit_row[i] |= (1 << (map[i][j] - '0'));
bit_box[(i / 3) * 3 + j / 3] |= (1 << (map[i][j] - '0'));
}
if (map[j][i] != '0') {
bit_col[i] |= (1 << (map[j][i] - '0'));
}
}
}
dfs(0, 0, 0);
return 0;
}