program A1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  N,i,j:integer;
  A:array [-300..500,-300..500] of Longint;
  B:array [-300..500,-300..500] of Longint;

  dx,dy:integer;
  x,y:integer;

Procedure Find(by,bx:integer);
var
 i:integer;
 Number:integer;
 Count:integer;
 x,y:integer;
 sdv:Longint;
begin
  number:=0;
  Count:=0;
  For i:=1 to 200 do
  begin
    Sdv:=0;
    y:=by-i;
    x:=bx;

    dx:=1;
    dy:=-1;
    while Sdv <> i*4 do
    begin
    inc(Sdv);
    if A[y,x]<>0 then
    begin
      inc(count);
      NUmber:= A[y,x];
    end;

    if (y=by) or (x=bx) then
    begin
      if (dx=1) and (dy=1) then begin dx:=-1; dy:=1; end
      else if (dx=-1) and (dy=1) then begin dx:=-1; dy:=-1; end
      else if (dx=-1) and (dy=-1) then begin dx:=1; dy:=-1; end
      else if (dx=1) and (dy=-1) then begin dx:=1; dy:=1; end;
    end;
    x:=x+dx;
    y:=y+dy;

    end;

    if count = 1 then
    begin
        B[by,bx]:= Number;
        break;
    end;
    If count > 1 then Break;

  end;

end;

begin
  { TODO -oUser -cConsole Main : Insert code here }


  AssignFile(input,'input.txt');
  reset(input);
  read(N);

  For i:=1 to N do
  For j:=1 to N do
  begin
    read(A[i,j]);
    B[i,j]:=A[i,j];
  end;


  For i:=1 to N do
  For j:=1 to N do
   if A[i,j] = 0 then
         find(i,j);

  close(input);

  AssignFile(output,'output.txt');
  rewrite(output);

  For i:=1 to N do begin
  For j:=1 to N do begin
   Write(B[i,j], ' ');
  end;
  writeln;
  end;




end.
