// Aizu Vol-10 1007: JPEG Compression
// 2017.8.18 bal4u@uu

#include <stdio.h>

int a[12][12];

int main()
{
	int n, cno;
	int r, c, k, m, f;

	for (cno = 1; ; cno++) {
		scanf("%d", &n); if (!n) break;
		m = k = f = 1;
		do {
			if (f) for (r = k - 1, c = 0; r >= 0; r--, c++) a[r][c] = m++;
			else   for (r = 0, c = k - 1; c >= 0; r++, c--) a[r][c] = m++;
			f = !f;
		} while (++k <= n);
		k = n - 1;
		do {
			if (f) for (r = n - 1, c = n - k; c < n; r--, c++) a[r][c] = m++;
			else   for (r = n - k, c = n - 1; r < n; r++, c--) a[r][c] = m++;
			f = !f;
		} while (--k >= 1);
		printf("Case %d:\n", cno);
		for (r = 0; r < n; r++) {
			for (c = 0; c < n; c++) printf("%3d", a[r][c]);
			putchar('\n');
		}
	}
	return 0;
}