while n = gets.to_i do
  break if n.zero?
  tile = Array.new(n).map!{Array.new(n)}
  tile[y=n/2+1][x=n/2]=1
  2.upto(n*n){|i|
  if tile[y=(y+1)%n][x=(x+1)%n].nil?
   tile[y][x]=i
  else
    loop{
      x=(x+n-1)%n
      y=(y+1)%n
    if tile[y][x].nil?
      tile[y][x] = i
      break
    end
    }
  end
  }
  tile.each{|ary|
    puts ary.join(" ")
  }
end