while n = gets.chomp.to_i
break if n == 0

ary = Array.new(n).map{Array.new(n,0)}

x = n / 2
y = (n + 1) / 2
k = 1
ary[y][x] = k

while k  < n * n
x += 1
x = 0 if x >= n
y += 1
y = 0 if y >= n

while ary[y][x] > 0
x -= 1
x = n - 1 if x < 0 
y += 1
y = 0 if y >= n 
end
k += 1
ary[y][x] = k
end
puts ary.map{|i| i.map{|j| sprintf("%4d",j)}.join}
end

