program Znn;
uses
  windows;

var f,f2:text;
    n,t,t2,t3,t4:integer;
    m,ma:array[-201..401,-201..401] of longint;

function FindThis(t,t2,d:longint):longint;
var x,x2,y,y2, tt,tt2:integer;
    found:integer;
    last:longint;


begin
 found:=0;
 x:=t-d;x2:=t+d; y:=t2-d; y2:=t2+d;
 for tt:=x to x2 do
 begin
  if (m[tt,y])<>0 then begin inc(found); last:=m[tt,y] end;
  if (m[tt,y2])<>0 then begin inc(found); last:=m[tt,y2] end;
 end;

 for tt:=y+1 to y2-1 do
 begin
  if (m[x,tt])<>0 then begin inc(found); last:=m[x,tt] end;
  if (m[x2,tt])<>0 then begin inc(found); last:=m[x2,tt] end;
 end;

 if (found=0) and (d<200) then result:=FindThis(t,t2,d+1)
  else
   begin
    if (found=1) then result:=last else result:=0;
   end;

end;


begin
  assignfile(f,'input.txt');
  reset(f);
  assignfile(f2,'output.txt');
  rewrite(f2);
  readln(f,n);

  fillchar(m,sizeof(m),0);
  for t:=1 to n do
   for t2:=1 to n do read(f,m[t,t2]);

//  for t:=0 to 201 do begin m[0,t]:=0; m[201,t]:=0; m[t,0]:=0; m[t,201]:=0; end;

  for t:=1 to n do
  begin
    for t2:=1 to n do
    begin
     if m[t,t2]=0 then ma[t,t2]:=FindThis(t,t2,1) else ma[t,t2]:=m[t,t2];
     write(f2,ma[t,t2],' ');

    end;

    writeln(f2,'');
  end;



  closefile(f2);
  if ma[1,1]=0 then ;
end.
