Program exc1;
  Var a:array [-1200..1200,-1200..1200] of longint;
      b:array [1..200,1..200] of longint;
      max:longint;
      n,k,y,x,i,j:longint;
      f,f1:boolean;
begin
 Assign(input,'input.txt');
 Reset(input);
 Read(n);
 fillchar(a,sizeof(a),0);
 fillchar(b,sizeof(b),0);
 For i:=1 to n do
  for j:=1 to n do
   read(a[i,j]);
 For y:=1 to n do
  for x:=1 to n do
   begin
     If a[y,x]<>0 then begin b[y,x]:=a[y,x]; continue; end;
     k:=0;
     max:=0;
     f1:=false;
     f:=false;
     While (y-k>0)or(x-k>0)or(y+k<=n)or(x+k<=n) do
     begin
     if b[y,x]<>0 then break;
     If f1 then break;
     inc(k);
     j:=x-k;
     i:=y;
     max:=0;
     f:=false;
     f1:=false;
     While j<>x do begin
        inc(j);
        dec(i);
        If a[i,j]<>0 then If not f then begin max:=a[i,j]; f:=true; end
                                   else begin f1:=true; break; end;
      end;
     If f1 then begin b[y,x]:=0; continue; end;
    While i<>y do begin
       inc(i);
       inc(j);
       If a[i,j]<>0 then If not f then begin max:=a[i,j]; f:=true; end
                                   else begin f1:=true; break; end;
      end;
     If f1 then begin b[y,x]:=0; continue; end;
    While j<>x do begin
      dec(j);
      inc(i);
      If a[i,j]<>0 then If not f then begin max:=a[i,j]; f:=true; end
                                   else begin f1:=true; break; end;
      end;
     If f1 then begin b[y,x]:=0; continue; end;
    While i<>y {!!!!!} do begin
       dec(i);
       dec(j);
       If a[i,j]<>0 then If not f then begin max:=a[i,j]; f:=true; end
                                   else begin f1:=true; break; end;
      end;
     If f1 then begin b[y,x]:=0; continue; end;
     b[y,x]:=max;
      end;
  end;
Assign(output,'output.txt');
Rewrite(output);
 For i:=1 to n do
  begin
    for j:=1 to n do
     Write(b[i,j],' ');
     WriteLn;
  end;
Close(output);
end.