program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
a,b:array[0..202,0..202]of longint;
c,d:array[1..1000]of integer;
qaz,zaq,max,sh,n,i,j,k,l,zn,kol,met:integer;
f:text;

{function ab(i:integer):integer;
begin
if i<0 then ab:=-i
else
ab:=i;
end;
}
begin
assign(f,'input.txt');
reset(f);
read(f,n);
for i:=1 to n do
for j:=1 to n do
read(f,a[i,j]);
close(f);
assign(f,'output.txt');
rewrite(f);

for i:=1 to n do
begin
 for j:=1 to n do
  begin
  if a[i,j]<>0 then
   b[i,j]:=a[i,j]
  else
   begin
   max:=0;
   qaz:=n-i+n-j;
   zaq:=i+j;
   if qaz>=zaq then
    sh:=qaz
   else
    sh:=zaq;
   for k:=1 to sh do
    c[k]:=0;
   for k:=1 to n do
    for l:=1 to n do
   begin
    if (a[k,l]<>0) then
     begin
     sh:=abs(k-i)+abs(l-j);
     if max=0 then
        max:=sh;

     inc(c[sh]);
     d[sh]:=a[k,l];

     end;
    end;
   sh:=1;
   k:=1;
   while (c[k]=0)and(k<=max)do
   inc(k);
   if c[k]=1 then
    b[i,j]:=d[k]
   else
    b[i,j]:=0;
end;
    write(f,b[i,j],' ')
  end;
if i<n then
 writeln(f);
end;
close(f);

end.

