### main

cnum = 1

loop do
  n = gets.strip.to_i
  break if n == 0

  mtx = n.times.map{[]}

  maxsum = (n - 1) * 2
  id = 1
  prt = 0

  for sum in (0..maxsum)
    if prt == 0
      x = [sum - (n - 1), 0].max
      y = sum - x
      while x < n && y >= 0
        mtx[y][x] = id
        id += 1
        x += 1
        y -= 1
      end
    else
      y = [sum - (n - 1), 0].max
      x = sum - y
      while y < n && x >= 0
        mtx[y][x] = id
        id += 1
        y += 1
        x -= 1
      end
    end

    prt = 1 - prt
  end
  #p mtx

  puts "Case #{cnum}:"

  for hl in mtx
    puts hl.map{|id| sprintf("%3d", id)}.join('')
  end

  cnum += 1
end