program prob_a;

const inf = 1000000001;

type vect = record
  dx, dy: longint;
end;

var a, b, left, right, up, down: array[0..201, 0..201] of longint;
    vectors: array[1..4] of vect;
    i, j, n, k: longint;
    v1, v2, v3, v4: vect;
    tvect: vect;

function vvalue (apar: integer): longint;
begin
  result := a[i + vectors[apar].dy, j + vectors[apar].dx];
end;

function absval (apar: integer): longint;
begin
  result := abs(vectors[apar].dx) + abs(vectors[apar].dy);
end;

function subvect(apar, bpar: vect): vect;
var tres: vect;
begin
        tres.dx := apar.dx - bpar.dx;
        tres.dy := apar.dy - bpar.dy;
end;

function min (apar, bpar: vect): vect;
begin
        if absval(apar) < absval(bpar) then min := apar else min := bpar;
end;

function minI (apar, bpar, cpar, dpar: vect): vect;
begin
  mini := min(min(apar, bpar ), min(cpar, dpar));
end;

begin
  assign (input, 'input.txt'); reset (input);
  assign (output, 'output.txt'); rewrite (output);

  read (n);
  for i := 1 to n do
        for j := 1 to n do read (a[i, j]);

  for i := 0 to 201 do
        for j := 0 to 201 do
        begin
                left[i, j].dx := inf;
                right[i, j].dx := inf;
                left[i, j].dy := inf;
                right[i, j].dy := inf;
        end;

  for i := 1 to n do
        for j := 1 to n do
        begin
          if a[i, j] <> 0 then
          begin
                left[i, j] := 0;
          end
          else
          begin
                left[i, j] := minI (left[i-1, j], left[i-1, j-1], left[i, j-1], left[i-1, j-1]);
          end;
  end;
  for i := n downto 1 do
        for j := n downto 1 do
        begin
          if a[i, j] <> 0 then
          begin
                left[i, j] := 0;
          end
          else
          begin
                left[i, j] := minI (left[i+1, j], left[i+1, j+1], left[i, j+1], left[i+1, j+1]);
          end;
  end;


  for i := 1 to n do
    for j := 1 to n do
      if a[i, j] = 0 then
      begin
        vectors[1].dy := -up[i, j]; vectors[1].dx := 0;
        vectors[2].dy := down[i, j]; vectors[2].dx := 0;
        vectors[3].dy := 0; vectors[3].dx := -left[i, j];
        vectors[4].dy := 0; vectors[4].dx := right[i, j];
        k := 1;
        while (k < 4) do
          if absval(k) > absval(k+1) then
          begin
            tvect := vectors[k];
            vectors[k] := vectors[k+1];
            vectors[k+1] := tvect;
            if k <> 1 then dec(k);
          end
          else inc(k);
        if absval(1) <> absval(2) then b[i, j] := vvalue(1)
        else b[i, j] := 0;
      end else b[i, j] := a[i, j];

  for i := 1 to n do
  begin
        for j := 1 to n do write (b[i, j], ' ');
        writeln;
  end;
  close (input); close (output);
end.