cnt = 1
while gets
	n = $_.to_i
	break if n==0
	puts "Case " + cnt.to_s + ":"
	arr = Array.new(n) { Array.new(n) }
	a = 1
	for i in 0...n
		if i % 2 == 0
			for j in 0..i
				arr[i-j][j] = a
				a += 1
			end
		else
			for j in 0..i
				arr[j][i-j] = a
				a += 1
			end
		end
	end
	a = n*n
	for i in 0...(n-1)
		if i % 2 == 0
			for j in 0..i
				arr[n-i+j-1][n-j-1] = a
				a -= 1
			end
		else
			for j in 0..i
				arr[n-j-1][n-i+j-1] = a
				a -= 1
			end
		end
	end
	n.times do |i|
		puts arr[i].map{|j| "%3d".%(j)}.join("")
	end
	cnt += 1
end