def PrintSquare( board,n )
	n.times{ |i|
		n.times{ |j|
			printf( "%4d",board[ j ][ i ])
		}
		puts
	}
end

def PutNext( board, n, x, y, num )
	next_x = x + 1
	next_y = y + 1
	while true
		next_x = 0     	if next_x >= n
		next_x = n - 1 	if next_x < 0
		next_y = 0 		if next_y >= n
		next_y = n - 1	if next_y < 0
		break if board[ next_x ][ next_y ] == 0
		next_x -= 1
		next_y += 1
	end

	board[ next_x ][ next_y ] = num
	return board, next_x, next_y
end

def MagicSquare( n )
	next_num = 1
	board = Array.new( n ){ Array.new( n, 0) }

	mid = n / 2
	x = mid
	y = mid + 1

	board[ x ][ y ] = next_num
	2.upto( n * n ){ |count|
		board, x, y = PutNext( board, n, x, y, count )
	}
	PrintSquare( board, n )	
end

def main
	questions = Array.new
	while line = $stdin.gets 
		n = line.chomp.to_i
		break if n == 0
		questions << n
	end
	questions.each{ |n|
		MagicSquare( n )
	}
end
main
