{$apptype console}

uses
  Math;

var
  a, b: array[-1000..1000, -1000..1000] of longint;
  i, j, i1, j1, k, n, t: integer;

function Find(y, x: integer): longint;
  function search(y, x, r: integer): longint;
  var
    i: integer;
    found: longint;
  begin
    found := -1;
    for i := 0 to r - 1 do begin
      if (a[y - r + i, x + i] > 0) then begin
        if (found >= 0) then begin
          found := 0;
          Break;
        end
        else
          found := a[y - r + i, x + i];
      end;
      if (a[y - i, x - r + i] > 0) then begin
        if (found >= 0) then begin
          found := 0;
          Break;
        end
        else
          found := a[y - i, x - r + i];
      end;
      if (a[y + i, x + r - i] > 0) then begin
        if (found >= 0) then begin
          found := 0;
          Break;
        end
        else
          found := a[y + i, x + r - i];
      end;
      if (a[y + r - i, x - i] > 0) then begin
        if (found >= 0) then begin
          found := 0;
          Break;
        end
        else
          found := a[y + r - i, x - i];
      end;
    end;
    Result := found;
  end;

var
  i: integer;
begin
  for i := 1 to n do begin
    Result := search(y, x, i);
    if (Result >= 0) then
      Exit;
  end;
end;

begin
  FillChar(b, SizeOf(b), 0);
  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 := 1 to n do
    for j := 1 to n do
      if (a[i, j] = 0) then
        b[i, j] := Find(i, j);

  for i := 1 to n do begin
    for j := 1 to n do
      write(Max(a[i, j], b[i, j]), ' ');
    writeln;
  end;

  close(input);
  close(output);
end.