program Project2;

{$APPTYPE CONSOLE}
var
  f1,f2: textfile;
  a: array[1..110,1..110] of integer;
  x,y: integer;
  boolka: boolean;
  r: char;
  m,n,i,j: integer;
  c: integer;

begin
  assignfile(f1,'F.in');
  assignfile(f2,'F.out');
  reset(f1);
  rewrite(f2);

  readln(f1,n);
  m:=1;
  x:=55;
  y:=55;
  r:='d';
  c:=1;
  a[x,y]:=c;
  while m<>n+1 do
  begin
    for i:=1 to m do
    begin
      case r of
        'l': x:=x+1;
        'r': x:=x-1;
        'u': y:=y-1;
        'd': y:=y+1;
      end;
      c:=c+1;
      a[x,y]:=c;
    end;
    case r of
      'l': r:='d';
      'r': r:='u';
      'u': r:='l';
      'd': r:='r';
    end;
    for i:=1 to m do
    begin
      case r of
        'l': x:=x+1;
        'r': x:=x-1;
        'u': y:=y-1;
        'd': y:=y+1;
      end;
      c:=c+1;
      a[x,y]:=c;
    end;
    case r of
      'l': r:='d';
      'r': r:='u';
      'u': r:='l';
      'd': r:='r';
    end;
    m:=m+1;
  end;
  for i:=1 to 110 do
  begin
    for j:=1 to 110 do
    begin
      if a[i,j]<>0 then
      begin
        if a[i,j]<=n*n then
        begin
          if boolka then write(f2,' ');
          write(f2,a[i,j]);
          boolka:=true;
        end;  
      end;
    end;
    if boolka then writeln(f2);
    boolka:=false;
  end;
  closefile(f1);
  closefile(f2);
end.
