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