program problem_fuck;

{$APPTYPE CONSOLE}
var
 f:TextFile;
 a,b:array[1..200,1..200] of longint;
 n,i,j,k,l,x,y:byte;
 p:longint;
 z:boolean;
begin
 assignfile(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]);
 closefile(f);

 for i:=1 to n do
  for j:=1 to n do
   if a[i,j]=0 then
    begin

     l:=1;
     z:=True;
     p:=0;
     while z do
      begin

       for k:=1 to l do
        begin
         if (i+1 -k>0)and(i+1 -k<=n)and(j-l-1 +k>0)and(j-l-1 +k<=n) then
         if (a[i+1 -k,j-l-1 +k]<>0) then
          begin
           Inc(p);
           x:=j -l-1+k;
           y:=i +1-k;
          end;
         if (i-l-1 +k>0)and(i-l-1 +k<=n)and(j-1 +k>0)and(j-1 +k<=n) then
         if (a[i-l-1 +k,j-1 +k]<>0) then
          begin
           Inc(p);
           x:=j-1 +k;
           y:=i-l-1 +k;
          end;
         if (i-1 +k>0)and(i-1 +k<=n)and(j+l+1 -k>0)and(j+l+1 -k<=n) then
         if (a[i-1 +k,j+l+1 -k]<>0) then
          begin
           Inc(p);
           x:=j+l+1-k;
           y:=i-1+k;
          end;
         if (i+l+1 -k>0)and(i+l+1 -k<=n)and(j+1 -k>0)and(j+1 -k<=n) then
         if (a[i+l+1 -k,j+1 -k]<>0) then
          begin
           Inc(p);
           x:=j+1 -k;
           y:=i+l+1 -k;
          end;
        end;
        if p=1 then
         begin
          b[i,j]:=a[y,x];
          z:=false;
         end;
        if p>1 then
         begin
          b[i,j]:=0;
          z:=false;
         end;
        if p=0 then
         Inc(l);
        if l>2*n then
         begin
          z:=false;
          b[i,j]:=0;
         end;

      end;  {while}

    end
   else
    b[i,j]:=a[i,j];

 assignfile(f,'output.txt');
 rewrite(f);
 for i:=1 to n do
  begin
   for j:=1 to n do
   if j=n then
    write(f,b[i,j]) else write(f,b[i,j],' ');
   if i<>n then writeln(f);
  end;
 closefile(f);
end.
