class Array
  def cget(i)
    self[i % self.size]
  end
end

readlines.each do |l|
  n = l.to_i
  break if n==0
  table = Array.new(n){ Array.new(n) }
  x,y = n/2 + 1, n/2
  table[x][y] = 1
  (2..(n*n)).each do |i|
    x,y = x+1,y+1
    while table.cget(x).cget(y)
      x,y = x+1,y-1
    end
    table[x%n][y%n] = i
  end
  puts table.map{|i| i.map{|j| sprintf("%#{(n*n).to_s.size}d", j)}.join(" ") }
end