/*#include<stdio.h>
int main()
{
int n, i;
scanf("%d", &n);
for(i=0; i<=n; i++)
printf("%d\n", i);
return 0;
}*/
/*#include<stdio.h>
int main()
{
int n, sum=0;
scanf("%d", &n);
for(int i=0; i<=n; i+=2)
sum += i;
printf("%d", sum);
return 0;
}*/
/*#include<stdio.h>
int main()
{
char n;
while(n!='q')
{
scanf("%c ", &n);
printf("%c\n", n);
}
return 0;
}*/
/*#include<stdio.h>
int main()
{
int n, sum = 0, i;
scanf("%d", &n);
for(i=1; ; i++)
{
sum += i;
if(n<=sum) break;
}
printf("%d", i);
return 0;
}*/
/*#include<stdio.h>
int main()
{
int a, b, i, j;
scanf("%d %d", &a, &b);
for(i=1; i<=a; i++)
{
for(j=1; j<=b; j++)
{
printf("%d %d\n", i, j);
}
}
return 0;
}*/
/*#include<stdio.h>
int main()
{
int n, i;
scanf("%X", &n);
for(i=1; i<=15; i++)
{
printf("%X*%X=%X\n", n, i, n*i);
}
return 0;
}*/
/*#include<stdio.h>
int main()
{
int i, n;
scanf("%d", &n);
for(i=1; i<=n; i++)
{
if(i%3==0)
printf("X ");
else
printf("%d ", i);
}
return 0;
}
*/
/*#include<stdio.h>
int main()
{
int i, j, k, r, g, b, sum = 0;
scanf("%d %d %d", &r, &g, &b);
for(i=0; i<r; i++)
{
for(j=0; j<g; j++)
{
for(k=0; k<b; k++)
{
printf("%d %d %d\n", i, j, k);
sum++;
}
}
}
printf("%d", sum);
}*/
/*#include<stdio.h>
int main()
{
int h, b, c, s;
long long int res;
scanf("%d %d %d %d", &h, &b, &c, &s);
res = (long long int)h*b*c*s;
printf("%.1f MB", ( ( (double)res / 8 ) / 1024 ) / 1024 );
return 0;
}*/
/*#include<stdio.h>
int main()
{
long long int w, h, b;
scanf("%lld %lld %lld", &w, &h, &b);
printf("%.2f MB", ((((double)(w*h*b)/8)/1024)/1024));
return 0;
}*/
/*#include<stdio.h>
int main()
{
long long int n, i, sum=0;
scanf("%lld", &n);
for(i=1; ; i++)
{
sum += i;
if(n<=sum) break;
}
printf("%lld", sum);
return 0;
}*/
/*#include<stdio.h>
int main()
{
int n, i;
scanf("%d", &n);
for(i=1; i<=n; i++)
if(i%3!=0) printf("%d ", i);
return 0;
}*/
/*#include<stdio.h>
int main()
{
int a, d, n;
scanf("%d %d %d", &a, &d, &n);
printf("%d", a+(n-1)*d);
return 0;
}*/
/*#include<stdio.h>
#include <math.h>
int main()
{
long long int a, r, n;
scanf("%lld %lld %lld", &a, &r, &n);
printf("%lld", a*(long long int)pow(r,n-1));
return 0;
}*/
/*#include<stdio.h>
int main()
{
long long int a, m, d, n;
scanf("%lld %lld %lld %lld", &a, &m, &d, &n);
for(int i=1; i<n; i++)
{
a*=m;
a+=d;
}
printf("%lld", a);
return 0;
}*/
/*#include<stdio.h>
int main()
{
int a, b, c, day=1;
scanf("%d %d %d", &a, &b, &c);
while(day%a!=0 || day%b!=0 || day%c!=0) day++;
printf("%d", day);
return 0;
}*/
/*#include<stdio.h>
int main()
{
int n, i, t;
int arr[23] = {};
scanf("%d", &n);
for(i=0; i<n; i++)
{
scanf("%d", &t);
arr[t]++;
}
for(i=1; i<=23; i++)
{
printf("%d ", arr[i]);
}
return 0;
}
*/
/*#include<stdio.h>
int main()
{
int i, n;
int arr[10000];
scanf("%d", &n);
for(i=n; i>=1; i--)
scanf("%d", &arr[i]);
for(i=1; i<=n; i++)
printf("%d ", arr[i]);
return 0;
}*/
/*#include<stdio.h>
int main()
{
int n, i, t, low;
scanf("%d", &n);
scanf("%d", &low);
for(i=1; i<n; i++)
{
scanf("%d", &t);
if(low>t) low = t;
}
printf("%d", low);
return 0;
}*/
/*#include<stdio.h>
int main()
{
int n, i, j, k, t;
int arr[20][20] = {};
scanf("%d", &n);
for(i=1; i<=n; i++)
{
scanf("%d %d", &k, &t);
arr[k][t] = 1;
}
for(i=1; i<=19; i++)
{
for(j=1; j<=19; j++)
{
printf("%d ", arr[i][j]);
}
printf("\n");
}
return 0;
}
*/
/*#include<stdio.h>
int main()
{
int n, i, j, x, y;
int a[20][20]= {};
for(i=1; i<=19; i++)
for(j=1; j<=19; j++)
scanf("%d", &a[i][j]);
scanf("%d", &n);
for(i=1; i<=n; i++)
{
scanf("%d %d", &x, &y);
for(j=1; j<=19; j++)
{
if(a[x][j]==0) a[x][j]=1;
else a[x][j] = 0;
}
for(j=1; j<=19; j++)
{
if(a[j][y]==0) a[j][y]=1;
else a[j][y] = 0;
}
}
for(i=1; i<=19; i++)
{
for(j=1; j<=19; j++)
{
printf("%d ", a[i][j]);
}
printf("\n");
}
return 0;
}*/
/*#include<stdio.h>
int main()
{
int h, w, n, l, d, x, y, i, j, x1, y1;
int arr[101][101] = {};
scanf("%d %d", &h, &w);
scanf("%d", &n);
for(i=1; i<=n; i++)
{
scanf("%d %d %d %d", &l, &d, &x, &y);
x1 = 0;
y1 = 0;
for(j=1; j<=l; j++)
{
arr[x+x1][y+y1] = 1;
if(d==0) y1++;
else x1++;
}
}
for(i=1; i<=h; i++)
{
for(j=1; j<=w; j++)
{
printf("%d ", arr[i][j]);
}
printf("\n");
}
}*/
#include<stdio.h>
int main()
{
int i, j, f=0, x=2, y=2;
int arr[11][11] = {};
for(i=1; i<=10; i++)
{
for(j=1; j<=10; j++)
{
scanf("%d", &arr[i][j]);
}
}
if(arr[x][y] == 2) f = 1;
arr[x][y] = 9;
while(f!=1)
{
if(arr[x][y+1]==0)
{
y++;
arr[x][y] = 9;
}
else if(arr[x][y+1]==2)
{
y++;
arr[x][y] = 9;
f = 1;
}
else if(arr[x+1][y]==0)
{
x++;
arr[x][y] = 9;
}
else if(arr[x+1][y]==2)
{
x++;
arr[x][y] = 9;
f = 1;
}
else f = 1;
}
for(i=1; i<=10; i++)
{
for(j=1; j<=10; j++)
{
printf("%d ", arr[i][j]);
}
printf("\n");
}
return 0;
}