while (n=gets.to_i)!=0
  mt=Array.new(n).map{Array.new(n,0)}
  y,x=n/2,n/2-1
  (1..n**2).each do |i|
    y,x=(y+1)%n,(x+1)%n
    if mt[y][x]!=0
      y,x=(y+1)%n,(x-1)%n 
    end
    mt[y][x]=i
  end
  mt.each do |l|
    puts l.map{|j| printf("%4d",j)}.join
  end
end