#include<bits/stdc++.h>
using namespace std;
const int N = 15;
int a[N][N];
int rep(int x){
return x < 3;
}
void dfs(int x, int y) {
if (a[x][y] != 0){
if (x == 9 && y == 9)return;
else if (y == 9)dfs(x + 1,1);
else dfs(x,y + 1);
}else{
int h[10],l[10],f[10];
for (int j = 1;j <= 9;++j){
if (j != y)h[j] = a[x][j];
}
for (int j = 1;j <= 9;++j){
if (j != x)l[j] = a[j][y];
}
int flag = 0;
for (int j = x / 3 + rep(x);j <= x / 3 + 2 + rep(x);++j){
for (int k = y / 3 + rep(y);k <= y / 3 + 2 + rep(x);++k){
if (j != x || k != y){
flag++;
f[flag] = a[j][k];
}
}
}
for (int j = 1;j <= 9;++j){
bool use = false;
for (int k = 1;k <= 8;++k){
if (j == h[k] || j == l[k] || j == f[k]){
use = true;
}
}
if (use == false){
a[x][y] = j;
break;
}
}
if (x == 9 && y == 9)return;
else if (y == 9)dfs(x + 1,1);
else dfs(x,y + 1);
}
}
int main() {
for (int i = 1; i <= 9; ++i) {
for (int j = 1; j <= 9; ++j) {
scanf("%d", &a[i][j]);
}
}
dfs(1, 1);
for (int i = 1;i <= 9;++i){
for (int j = 1;j <= 9;++j){
printf("%d ",a[i][j]);
}
printf("\n");
}
return 0;
}