program _________a;
 var
     f,f1:text;
     i,j,k,m,n,s,l,q,a_i_j:longint;
     a:array [1..200,1..200] of longint;
     c,b:array [1..40000] of record x,y:integer;end;
 begin
   assign(f,'input.txt');reset(f);
   assign(f1,'output.txt');rewrite(f1);
   read(f,n);k:=0;m:=0;
   for i:=1 to n do for j:=1 to n do
   begin
     read(f,a[i,j]);
     if a[i,j]<>0 then
     begin
       inc(k);
       c[k].x:=j;
       c[k].y:=i;
     end else begin
       inc(m);
       b[m].x:=j;
       b[m].y:=i;
     end;
   end;
   for i:=1 to m do
   begin
     s:=2000;l:=1;a_i_j:=0;
     for j:=1 to k do
     begin
       q:=abs(b[i].x-c[j].x)+abs(b[i].y-c[j].y);
       if q<s then
       begin
         a_i_j:=a[c[j].y,c[j].x];
         s:=abs(b[i].x-c[j].x)+abs(b[i].y-c[j].y);
         l:=0;
       end;
       if q=s then inc(l);
     end;
     if l=1 then a[b[i].y,b[i].x]:=a_i_j;
   end;
   for i:=1 to n do
   begin
     for j:=1 to n do write(f1,a[i,j],' ');
     writeln(f1);
   end;
   close(f);
   close(f1);
 end.
