#!/usr/bin/ruby
# coding: utf-8

PI = Math.acos(-1)

def padding(n)
  ("    " + n.to_s)[-4, 4]
end

def solve(n)
  f = Array.new(n)
  for i in 0...n
    f[i] = Array.new(n, 0)
  end

  x = 1 + n/2
  y = n/2
  for k in 1..(n*n)
    while f[x][y] > 0
      x += 1
      y += n-1
      x %= n
      y %= n
    end
    f[x][y] = k
    x += 1
    y += 1
    x %= n
    y %= n
  end

  for i in 0...n
    for j in 0...n
      print padding(f[i][j])
    end
    puts ''
  end
end

while true
  n = STDIN.gets.to_i
  if n == 0
    break
  else
    solve(n)
  end
end