index = 0
table_cases = []
while buf = gets.to_i
  break if buf == 0
  table = Array.new(buf) do
    Array.new(buf, 0)
  end
  buf.times do |x|
    buf.times do |y|
      if buf > x + y
        table[x][y] = 1 + (x + y + 1) % 2 * ((x + y + 1) * (x + y) / 2 + y) + (x + y + 2) % 2 * ((x + y + 1) * (x + y) / 2 + x)
      else
        table[x][y] = buf ** 2 - (x + y + 1) % 2 * ((buf * 2 - (x + y + 1)) * (buf * 2 - (x + y + 1) - 1) / 2 + buf - (y + 1)) - (x + y + 2) % 2 * ((buf * 2 - (x + y + 1)) * (buf * 2 - (x + y + 1) - 1) / 2 + buf - (x + 1))
      end
    end
  end
  index += 1
  table_cases << ("Case #{index}:\n" + table.collect{|row| row.join(' ')}.join("\n"))
end
puts table_cases