
import std.stdio;

void show(int[][] square) {
  for(int i = 0; i < square.length; i++)
    for(int j = 0; j < square[i].length; j++)
      writef("%4d%s", square[i][j], j == square.length - 1 ? "\n" : "");
}

int[][] magic_square(int[][] square, int n) {
  int x = (n - 1) / 2;
  int y = (n - 1) / 2 - 1;
  int len = 0;
  while(len <= n * n) {
    x = (x + n) % n;
    y = (y + n) % n;
    if (square[x][y] == 0) {
      square[x][y] = len;
      x = x + 1;
      y = y + 1;
      len++;
    }
    else {
      x = x + 1;
      y = y - 1;
    }
  }
  return square;
}

void main() {
  for(int n; readf("%d\n", &n), n != 0;) {
    magic_square(new int[][](n, n), n).show;
  }
}