program problem_a;

{$APPTYPE CONSOLE}
label final;
var l,k,t,r,i,j,n,x,y,x0,y0,count,maybemax,max:longint;
    fi,fo:text;
    a,b:array [1..201,1..201] of longint;
    isnonnul: boolean;

begin
   isnonnul := false;
   AssignFile(fi,'input.txt');
   AssignFile(fo,'output.txt');
   reset(fi);
   rewrite(fo);
   read(fi,r);
   for k:= 1 to r do
      for  t := 1 to r do
         begin
            read(fi,a[t,k]);
            b[t,k] := a[t,k];
            if a[t,k] <> 0 then isnonnul := true;
         end;

   if not isnonnul then goto final;


   for i := 1to r do
   begin
      for j := 1 to r do
      begin
          if a[i,j] <> 0 then continue;
          count := 0;
          max := (r-i) + (r -j);

          maybemax := (r-i)+(j-1);
          if maybemax > max then
              max := maybemax;

          maybemax := (r-j)+ (i-1);
          if maybemax > max then
              max := maybemax;

          maybemax := (j-1) + (i - 1);
          if maybemax > max then
              max := maybemax;
          //inc(max,2);

          for n := 1 to max do
          begin
               for k := 1 to n do
               begin
                    x := i + k;
                    if (x > 0) and ( x < r +1) and ( count <2) then
                    begin
                        y := n -k +j;
                        if (y > 0) and ( y < r +1) and( count <2)then
                          if (a[x,y] <> 0 ) then
                          begin
                              inc(count);
                              y0 := y ;
                              x0 := x;
                          end;
                        y := j-n +k;
                        if (k <> n)and(y > 0) and ( y < r +1) and( count <2)then
                          if (a[x,y] <> 0 ) then
                          begin
                              inc(count);
                              y0 := y ;
                              x0 := x;
                          end;
                    end;// if x  first



                    x := i -k;
                    if (x > 0) and ( x < r +1) and ( count <2) then
                    begin
                        y := n -k +j;
                        if (y > 0) and ( y < r +1) and( count <2)then
                          if (a[x,y] <> 0 ) then
                          begin
                              inc(count);
                              y0 := y ;
                              x0 := x;
                          end;
                        y := j-n +k;
                        if (k <> n)and(y > 0) and ( y < r +1) and( count <2)then
                        if (a[x,y] <> 0 ) then
                          begin
                              inc(count);
                              y0 := y ;
                              x0 := x;
                          end;
                    end;// if x  second



                    y := j + k;
                    if (y > 0) and ( y < r +1) and ( count <2) then
                    begin
                        x := n -k +i;
                        if (x > 0) and ( x < r +1) and( count <2)then
                          if (a[x,y] <> 0 ) then
                          begin
                              inc(count);
                              y0 := y ;
                              x0 := x;
                          end;
                        x := i-n +k;
                        if (k <> n)and(x > 0) and ( x < r +1) and( count <2)then
                          if (a[x,y] <> 0 ) then
                          begin
                              inc(count);
                              y0 := y ;
                              x0 := x;
                          end;
                    end;// if y  first



                    y := j -k;
                    if (y > 0) and ( y < r +1) and ( count <2) then
                    begin
                        x := n -k +i;
                        if (x > 0) and ( x < r +1) and( count <2)then
                          if (a[x,y] <> 0 ) then
                          begin
                              inc(count);
                              y0 := y ;
                              x0 := x;
                          end;
                        x := i-n +k;
                        if (k <> n)and(x> 0) and ( x < r +1) and( count <2)then
                        if (a[x,y] <> 0 ) then
                          begin
                              inc(count);
                              y0 := y ;
                              x0 := x;
                          end;
                    end;// if y  second



                    if count >= 2 then break;


               end;// for k

               if count > 0 then break;

          end;// for n

          if count = 1 then
          begin
             b[i,j] := a[x0,y0];
          end;
      end; //for j
   end;  //for i


   final :

   for k := 1 to r do
   begin
      for t := 1 to r do
      begin
         write(fo,b[t,k]);
         write(fo,' ');

      end;
      if k <> r then writeln(fo);
   end;
   close(fi);
   close(fo);

end.
