program D_A;

{$APPTYPE CONSOLE}

Var
  A, B: array[-201..402, -201..402] of integer;
  N, i, j, x, y, z, c, k, e: integer;

begin
  Assign(input, 'INPUT.TXT'); Reset(input);
  Read(N);
  FillChar(A, SizeOf(A), 0);
  for j := 1 to N do
    for i := 1 to N do
      Read(A[j,i]);
  B := A;

  for j := 1 to N do
    for i := 1 to N do
      if A[j,i] = 0 then begin

  for c := 1 to N+1 do begin
    k := 0;
    for z := 0 to c-1 do begin
      if A[j-c+z, i-z] <> 0 then begin Inc(k); e := A[j-c+z, i-z]; end;
      if A[j+z, i-c+z] <> 0 then begin Inc(k); e := A[j+z, i-c+z]; end;
      if A[j+c-z, i+z] <> 0 then begin Inc(k); e := A[j+c-z, i+z]; end;
      if A[j-z, i+c-z] <> 0 then begin Inc(k); e := A[j-z, i+c-z]; end;
    end;
    if k > 1 then Break else
      if k = 1 then begin B[j,i] := e; Break; end;
  end;

      end;

  Assign(output, 'OUTPUT.TXT'); Rewrite(output);
  for j := 1 to N do begin
    for i := 1 to N do
      Write(B[j,i], ' ');
    Writeln;
  end;
end.