#!/usr/bin/ruby
t=0
while(n=gets.to_i)>0
	puts "Case #{t+=1}:"
	a=[]
	x=1
	c=1
	1.step(n){|i|
		b=[]
		1.step(i){b<<x;x+=1}
		b.reverse! if c>0
		c^=1
		a<<b
	}
	(n-1).step(1,-1){|i|
		b=[]
		1.step(i){b<<x;x+=1}
		b.reverse! if c>0
		c^=1
		a<<b
	}
	n.times{|i|
		n.times{|j|
			printf("%3d",a[i+j].shift)
		}
		puts
	}
end